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
12 changes: 11 additions & 1 deletion Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,13 @@ export async function activate(): Promise<void> {
getCustomConfigProviders().forEach(provider => void client.onRegisterCustomConfigurationProvider(provider));
});

disposables.push(vscode.workspace.onDidChangeConfiguration(onDidChangeSettings));
// These handlers for didChangeTextDocument and didOpenTextDocument are intentionally synchronous and are
// intended primarily to maintain openFileVersions with the most recent versions of files, as quickly as
// possible, without being delayed by awaits or queued behind other LSP messages, etc..
disposables.push(vscode.workspace.onDidChangeTextDocument(onDidChangeTextDocument));
disposables.push(vscode.workspace.onDidOpenTextDocument(onDidOpenTextDocument));

disposables.push(vscode.workspace.onDidChangeConfiguration(onDidChangeSettings));
disposables.push(vscode.window.onDidChangeTextEditorVisibleRanges((e) => clients.ActiveClient.enqueue(async () => onDidChangeTextEditorVisibleRanges(e))));
disposables.push(vscode.window.onDidChangeActiveTextEditor((e) => clients.ActiveClient.enqueue(async () => onDidChangeActiveTextEditor(e))));
ui.didChangeActiveEditor(); // Handle already active documents (for non-cpp files that we don't register didOpen).
Expand Down Expand Up @@ -303,6 +308,11 @@ function onDidChangeTextDocument(event: vscode.TextDocumentChangeEvent): void {
me.onDidChangeTextDocument(event);
}

function onDidOpenTextDocument(document: vscode.TextDocument): void {
const me: Client = clients.getClientFor(document.uri);
me.onDidOpenTextDocument(document);
}

let noActiveEditorTimeout: NodeJS.Timeout | undefined;

async function onDidChangeTextEditorVisibleRanges(event: vscode.TextEditorVisibleRangesChangeEvent): Promise<void> {
Expand Down
1 change: 0 additions & 1 deletion Extension/src/LanguageServer/protocolFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export function createProtocolFilter(): Middleware {
return;
}
// client.takeOwnership() will call client.TrackedDocuments.add() again, but that's ok. It's a Set.
client.onDidOpenTextDocument(document);
client.takeOwnership(document);
void sendMessage(document);
}
Expand Down