diff --git a/Extension/src/LanguageServer/extension.ts b/Extension/src/LanguageServer/extension.ts index 5b2ca2707..528635b1f 100644 --- a/Extension/src/LanguageServer/extension.ts +++ b/Extension/src/LanguageServer/extension.ts @@ -291,6 +291,8 @@ function onDidChangeSettings(event: vscode.ConfigurationChangeEvent): void { } } +let noActiveEditorTimeout: NodeJS.Timeout | undefined; + export function onDidChangeActiveTextEditor(editor?: vscode.TextEditor): void { /* need to notify the affected client(s) */ console.assert(clients !== undefined, "client should be available before active editor is changed"); @@ -298,7 +300,23 @@ export function onDidChangeActiveTextEditor(editor?: vscode.TextEditor): void { return; } - if (editor && util.isCppOrRelated(editor.document)) { + if (noActiveEditorTimeout) { + clearTimeout(noActiveEditorTimeout); + noActiveEditorTimeout = undefined; + } + + if (!editor) { + // When switching between documents, VS Code is setting the active editor to undefined + // temporarily, so this prevents the C++-related status bar items from flickering off/on. + noActiveEditorTimeout = setTimeout(() => { + activeDocument = ""; + ui.activeDocumentChanged(); + noActiveEditorTimeout = undefined; + }, 100); + return; + } + + if (util.isCppOrRelated(editor.document)) { // This is required for the UI to update correctly. clients.activeDocumentChanged(editor.document); if (util.isCpp(editor.document)) { diff --git a/Extension/src/LanguageServer/ui_new.ts b/Extension/src/LanguageServer/ui_new.ts index 58c5ba5f4..7fd91c245 100644 --- a/Extension/src/LanguageServer/ui_new.ts +++ b/Extension/src/LanguageServer/ui_new.ts @@ -189,6 +189,7 @@ export class NewUI implements UI { if (this.dbTimeout) { clearTimeout(this.dbTimeout); + this.dbTimeout = undefined; } } else { this.dbTimeout = setTimeout(() => { @@ -276,6 +277,7 @@ export class NewUI implements UI { if (this.dbTimeout) { clearTimeout(this.dbTimeout); + this.dbTimeout = undefined; } } else { this.dbTimeout = setTimeout(() => { @@ -314,6 +316,7 @@ export class NewUI implements UI { if (val) { this.intelliSenseStatusItem.text = "$(flame)"; this.intelliSenseStatusItem.detail = this.updatingIntelliSenseText; + this.flameTimeout = undefined; } else { this.flameTimeout = setTimeout(() => { if (this.intelliSenseStatusItem) {