Skip to content

Commit e704260

Browse files
committed
fix: fix missing diagnostics
1 parent ff293d9 commit e704260

File tree

2 files changed

+14
-24
lines changed

2 files changed

+14
-24
lines changed

src/api-linter.ts

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -103,42 +103,32 @@ export class APILinter {
103103
{ cwd: this.#workspacePath, encoding: "utf-8" }
104104
);
105105
if (result.status !== 0) {
106+
result.stderr = result.stderr.slice(result.stderr.indexOf(" "));
107+
result.stderr = result.stderr.slice(result.stderr.indexOf(" "));
108+
result.stderr = result.stderr.slice(result.stderr.indexOf(" ") + 1);
106109
return result.stderr
107-
.split(" ", 3)[2]
108110
.split("\n")
109111
.map((line) => {
110-
const [badFile, lineNo, columnNo, description] = line.split(":", 4);
112+
if (!line) {
113+
return;
114+
}
115+
const [badFile, lineNo, columnNo, ...descriptionParts] =
116+
line.split(":");
117+
const description = descriptionParts.join(":");
111118
if (file === badFile) {
112119
return new vscode.Diagnostic(
113-
toRange({
114-
start_position: {
115-
line_number: +lineNo,
116-
column_number: +columnNo,
117-
},
118-
end_position: {
119-
line_number: +lineNo,
120-
column_number: +columnNo,
121-
},
122-
}),
120+
new vscode.Range(+lineNo, +columnNo, +lineNo, +columnNo),
123121
description,
124122
vscode.DiagnosticSeverity.Error
125123
);
126124
}
127125
return new vscode.Diagnostic(
128-
toRange({
129-
start_position: {
130-
line_number: 0,
131-
column_number: 0,
132-
},
133-
end_position: {
134-
line_number: 0,
135-
column_number: 0,
136-
},
137-
}),
126+
new vscode.Range(0, 0, 0, 0),
138127
description,
139128
vscode.DiagnosticSeverity.Error
140129
);
141-
});
130+
})
131+
.filter((value): value is vscode.Diagnostic => value !== undefined);
142132
}
143133

144134
const output: Output[] = JSON.parse(result.stdout);

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function activate() {
6767
linter.setProtoPaths(config.get("protoPaths") as string[]);
6868

6969
// Lint the file.
70-
const filePath = vscode.workspace.asRelativePath(doc.uri);
70+
const filePath = vscode.workspace.asRelativePath(doc.uri, false);
7171
channel.appendLine(`Linting: ${filePath}`);
7272
diagnostics.set(doc.uri, linter.lint(filePath));
7373
});

0 commit comments

Comments
 (0)