Skip to content

Commit

Permalink
change error display length on all line instead of first char (issue: s…
Browse files Browse the repository at this point in the history
  • Loading branch information
rush93 committed Aug 31, 2022
1 parent d2d8c1e commit 8743761
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,28 @@ async function refreshDiagnostics(result: ResultType) {
for (let path in result.files) {
const pathItem = result.files[path]
const diagnostics: vscode.Diagnostic[] = []
let document: vscode.TextDocument = null
try {
document = await vscode.workspace.openTextDocument(
vscode.Uri.file(path)
)
} catch (error) {
setStatusBarError(error, "Document not found")
}
for (const messageItem of pathItem.messages) {
const line = messageItem.line ? messageItem.line - 1 : 0
const range = new vscode.Range(line, 0, line, 0)
let range: vscode.Range = null
if (document) {
const lineText = document?.lineAt(line)
range = new vscode.Range(
line,
lineText.firstNonWhitespaceCharacterIndex,
line,
lineText.range.end.character
)
} else {
range = new vscode.Range(line, 0, line, 0)
}
const diagnostic = new vscode.Diagnostic(
range,
messageItem.message,
Expand Down

0 comments on commit 8743761

Please sign in to comment.