Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,32 @@ 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");
if (clients === undefined) {
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)) {
Expand Down
3 changes: 3 additions & 0 deletions Extension/src/LanguageServer/ui_new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export class NewUI implements UI {

if (this.dbTimeout) {
clearTimeout(this.dbTimeout);
this.dbTimeout = undefined;
}
} else {
this.dbTimeout = setTimeout(() => {
Expand Down Expand Up @@ -276,6 +277,7 @@ export class NewUI implements UI {

if (this.dbTimeout) {
clearTimeout(this.dbTimeout);
this.dbTimeout = undefined;
}
} else {
this.dbTimeout = setTimeout(() => {
Expand Down Expand Up @@ -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) {
Expand Down