Skip to content

Commit 2ca08b0

Browse files
authored
Work around missing visible editor notifications (#13474)
1 parent 6b8b999 commit 2ca08b0

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

Extension/src/LanguageServer/client.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,12 +1366,6 @@ export class DefaultClient implements Client {
13661366
this.registerNotifications();
13671367

13681368
initializeIntervalTimer();
1369-
1370-
// If a file is already open when we activate, sometimes we don't get any notifications about visible
1371-
// or active text editors, visible ranges, or text selection. As a workaround, we trigger
1372-
// onDidChangeVisibleTextEditors here.
1373-
const cppEditors: vscode.TextEditor[] = vscode.window.visibleTextEditors.filter(e => util.isCpp(e.document));
1374-
await this.onDidChangeVisibleTextEditors(cppEditors);
13751369
}
13761370

13771371
// update all client configurations

Extension/src/LanguageServer/clientCollection.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ export class ClientCollection {
144144
this.activeClient.activate();
145145
await this.activeClient.didChangeActiveEditor(vscode.window.activeTextEditor);
146146
}
147-
const cppEditors: vscode.TextEditor[] = vscode.window.visibleTextEditors.filter(e => util.isCpp(e.document));
148-
await this.defaultClient.onDidChangeVisibleTextEditors(cppEditors);
149147
}
150148

151149
private async onDidChangeWorkspaceFolders(e?: vscode.WorkspaceFoldersChangeEvent): Promise<void> {

Extension/src/LanguageServer/protocolFilter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as path from 'path';
88
import * as vscode from 'vscode';
99
import { Middleware } from 'vscode-languageclient';
1010
import * as util from '../common';
11+
import { logAndReturn } from '../Utility/Async/returns';
1112
import { Client } from './client';
1213
import { clients } from './extension';
1314
import { shouldChangeFromCToCpp } from './utils';
@@ -40,6 +41,10 @@ export function createProtocolFilter(): Middleware {
4041
// client.takeOwnership() will call client.TrackedDocuments.add() again, but that's ok. It's a Set.
4142
client.takeOwnership(document);
4243
void sendMessage(document);
44+
const editor: vscode.TextEditor | undefined = vscode.window.visibleTextEditors.find(editor => editor.document === document);
45+
if (editor) {
46+
client.onDidChangeVisibleTextEditors([editor]).catch(logAndReturn.undefined);
47+
}
4348
}
4449
}
4550
},

0 commit comments

Comments
 (0)