Skip to content

Commit

Permalink
Merge pull request #58 from Discookie/ericsson/fix-double-parse
Browse files Browse the repository at this point in the history
Reduce number of `parse` calls
  • Loading branch information
csordasmarton authored Jan 31, 2022
2 parents 3cf7e4a + 2421b52 commit 65747d4
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/backend/processor/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ export class DiagnosticsApi {
filesToLoad.push(this._selectedEntry.file);
}

// Unload reports without calling parse
if (filesToLoad.length === 0) {
this._diagnosticEntries = new Map();
this._diagnosticsUpdated.fire();

return;
}

ExtensionApi.executorBridge.parseMetadata(...filesToLoad.map(file => Uri.file(file)))
.catch((err: any) => console.log(`Internal error in reloadDiagnostics: ${err}`));
}
Expand Down Expand Up @@ -143,9 +151,20 @@ export class DiagnosticsApi {
}

private onDocumentsChanged(event: TextEditor[]): void {
this._openedFiles = event.map(editor => editor.document.uri.fsPath);

this.reloadDiagnostics();
const newFiles = event
// Filters out the Output tab's extra events
.filter(editor => editor.document.uri.scheme !== 'output')
.map(editor => editor.document.uri.fsPath)
.sort();

// Only reload diagnostics when files are changed
if (
this._openedFiles.length !== newFiles.length ||
this._openedFiles.some((filePath, idx) => filePath !== newFiles[idx])
) {
this._openedFiles = newFiles;
this.reloadDiagnostics();
}
}

private onMetadataUpdated(_metadata: CheckerMetadata | undefined) {
Expand Down

0 comments on commit 65747d4

Please sign in to comment.