Skip to content

Commit

Permalink
fix #38
Browse files Browse the repository at this point in the history
  • Loading branch information
Lencerf committed Mar 18, 2020
1 parent 3d42fec commit 16c1149
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ export class Extension {
const diagsCollection: { [key: string]: vscode.Diagnostic[] } = {};
errors.forEach(e => {
const range = new vscode.Range(
new vscode.Position(e.line - 1, 0),
new vscode.Position(e.line, 0)
new vscode.Position(Math.max(e.line - 1, 0), 0),
new vscode.Position(Math.max(e.line, 1), 0)
);
const diag = new vscode.Diagnostic(
range,
Expand All @@ -203,8 +203,8 @@ export class Extension {
return;
}
const range = new vscode.Range(
new vscode.Position(f.line - 1, 0),
new vscode.Position(f.line, 0)
new vscode.Position(Math.max(f.line - 1, 0), 0),
new vscode.Position(Math.min(f.line, 1), 0)
);
const diag = new FlagDiagnostic(f.flag, range, f.message, warningType);
diag.source = 'Beancount';
Expand All @@ -214,9 +214,10 @@ export class Extension {
diagsCollection[f.file].push(diag);
});
this.diagnosticCollection.clear();
const mainBeanFile = this.getMainBeanFile();
for (const file of Object.keys(diagsCollection)) {
this.diagnosticCollection.set(
vscode.Uri.file(file),
vscode.Uri.file(existsSync(file) ? file : mainBeanFile),
diagsCollection[file]
);
}
Expand Down

0 comments on commit 16c1149

Please sign in to comment.