Skip to content

Commit 65747d4

Browse files
Merge pull request #58 from Discookie/ericsson/fix-double-parse
Reduce number of `parse` calls
2 parents 3cf7e4a + 2421b52 commit 65747d4

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/backend/processor/diagnostics.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ export class DiagnosticsApi {
7676
filesToLoad.push(this._selectedEntry.file);
7777
}
7878

79+
// Unload reports without calling parse
80+
if (filesToLoad.length === 0) {
81+
this._diagnosticEntries = new Map();
82+
this._diagnosticsUpdated.fire();
83+
84+
return;
85+
}
86+
7987
ExtensionApi.executorBridge.parseMetadata(...filesToLoad.map(file => Uri.file(file)))
8088
.catch((err: any) => console.log(`Internal error in reloadDiagnostics: ${err}`));
8189
}
@@ -143,9 +151,20 @@ export class DiagnosticsApi {
143151
}
144152

145153
private onDocumentsChanged(event: TextEditor[]): void {
146-
this._openedFiles = event.map(editor => editor.document.uri.fsPath);
147-
148-
this.reloadDiagnostics();
154+
const newFiles = event
155+
// Filters out the Output tab's extra events
156+
.filter(editor => editor.document.uri.scheme !== 'output')
157+
.map(editor => editor.document.uri.fsPath)
158+
.sort();
159+
160+
// Only reload diagnostics when files are changed
161+
if (
162+
this._openedFiles.length !== newFiles.length ||
163+
this._openedFiles.some((filePath, idx) => filePath !== newFiles[idx])
164+
) {
165+
this._openedFiles = newFiles;
166+
this.reloadDiagnostics();
167+
}
149168
}
150169

151170
private onMetadataUpdated(_metadata: CheckerMetadata | undefined) {

0 commit comments

Comments
 (0)