From f51404d9dbd11c67844583099833be943aef261d Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Tue, 29 Oct 2024 17:57:47 -0700 Subject: [PATCH 1/2] Switch to @vscode/dts. (#12901) --- Extension/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/package.json b/Extension/package.json index 97e425dcd0..f183a39f5c 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -6511,7 +6511,7 @@ "translations-generate": "set NODE_OPTIONS=--no-experimental-fetch && gulp translations-generate", "translations-import": "gulp translations-import", "import-edge-strings": "ts-node -T ./.scripts/import_edge_strings.ts", - "prep:dts": "yarn verify dts --quiet || (npx vscode-dts dev && npx vscode-dts main)", + "prep:dts": "yarn verify dts --quiet || (npx @vscode/dts dev && npx @vscode/dts main)", "build": "yarn prep:dts && echo [Building TypeScript code] && tsc --build tsconfig.json" }, "devDependencies": { From e45dbcec9bbef37cc1ecec0a38c9e34a612631aa Mon Sep 17 00:00:00 2001 From: Colen Garoutte-Carson <49173979+Colengms@users.noreply.github.com> Date: Tue, 29 Oct 2024 18:46:13 -0700 Subject: [PATCH 2/2] Fix issue with requests in protocolFilter.ts causing stalls (#12906) --- .../src/LanguageServer/protocolFilter.ts | 62 ++++++------------- 1 file changed, 18 insertions(+), 44 deletions(-) diff --git a/Extension/src/LanguageServer/protocolFilter.ts b/Extension/src/LanguageServer/protocolFilter.ts index 4dddbbcc22..b292c67b16 100644 --- a/Extension/src/LanguageServer/protocolFilter.ts +++ b/Extension/src/LanguageServer/protocolFilter.ts @@ -8,6 +8,7 @@ import * as path from 'path'; import * as vscode from 'vscode'; import { Middleware } from 'vscode-languageclient'; import * as util from '../common'; +import { logAndReturn } from '../Utility/Async/returns'; import { Client } from './client'; import { clients } from './extension'; import { shouldChangeFromCToCpp } from './utils'; @@ -18,14 +19,8 @@ export const ServerCancelled: number = -32802; let anyFileOpened: boolean = false; export function createProtocolFilter(): Middleware { - // Disabling lint for invoke handlers - const invoke1 = (a: any, next: (a: any) => any): any => clients.ActiveClient.enqueue(() => next(a)); - const invoke2 = (a: any, b: any, next: (a: any, b: any) => any): any => clients.ActiveClient.enqueue(() => next(a, b)); - const invoke3 = (a: any, b: any, c: any, next: (a: any, b: any, c: any) => any): any => clients.ActiveClient.enqueue(() => next(a, b, c)); - const invoke4 = (a: any, b: any, c: any, d: any, next: (a: any, b: any, c: any, d: any) => any): any => clients.ActiveClient.enqueue(() => next(a, b, c, d)); - return { - didOpen: async (document, sendMessage) => clients.ActiveClient.enqueue(async () => { + didOpen: async (document, sendMessage) => { if (!util.isCpp(document)) { return; } @@ -41,62 +36,41 @@ export function createProtocolFilter(): Middleware { const mappingString: string = baseFileName + "@" + document.fileName; client.addFileAssociations(mappingString, "cpp"); client.sendDidChangeSettings(); - document = await vscode.languages.setTextDocumentLanguage(document, "cpp"); + // This will cause the file to be closed and reopened. + void vscode.languages.setTextDocumentLanguage(document, "cpp"); + return; } // client.takeOwnership() will call client.TrackedDocuments.add() again, but that's ok. It's a Set. client.onDidOpenTextDocument(document); client.takeOwnership(document); - await sendMessage(document); - - // For a file already open when we activate, sometimes we don't get any notifications about visible - // or active text editors, visible ranges, or text selection. As a workaround, we trigger - // onDidChangeVisibleTextEditors here, only for the first file opened. - if (!anyFileOpened) { - anyFileOpened = true; - const cppEditors: vscode.TextEditor[] = vscode.window.visibleTextEditors.filter(e => util.isCpp(e.document)); - await client.onDidChangeVisibleTextEditors(cppEditors); - } + void sendMessage(document).then(() => { + // For a file already open when we activate, sometimes we don't get any notifications about visible + // or active text editors, visible ranges, or text selection. As a workaround, we trigger + // onDidChangeVisibleTextEditors here, only for the first file opened. + if (!anyFileOpened) { + anyFileOpened = true; + const cppEditors: vscode.TextEditor[] = vscode.window.visibleTextEditors.filter(e => util.isCpp(e.document)); + client.onDidChangeVisibleTextEditors(cppEditors).catch(logAndReturn.undefined); + } + }); } } - }), - didChange: invoke1, - willSave: invoke1, + }, willSaveWaitUntil: async (event, sendMessage) => { - // await clients.ActiveClient.ready; - // Don't use awaitUntilLanguageClientReady. - // Otherwise, the message can be delayed too long. const me: Client = clients.getClientFor(event.document.uri); if (me.TrackedDocuments.has(event.document.uri.toString())) { return sendMessage(event); } return []; }, - didSave: invoke1, - didClose: async (document, sendMessage) => clients.ActiveClient.enqueue(async () => { + didClose: async (document, sendMessage) => { const me: Client = clients.getClientFor(document.uri); const uriString: string = document.uri.toString(); if (me.TrackedDocuments.has(uriString)) { me.onDidCloseTextDocument(document); me.TrackedDocuments.delete(uriString); - await sendMessage(document); - } - }), - provideCompletionItem: invoke4, - resolveCompletionItem: invoke2, - provideHover: async (document, position, token, next: (document: any, position: any, token: any) => any) => clients.ActiveClient.enqueue(async () => { - const me: Client = clients.getClientFor(document.uri); - if (me.TrackedDocuments.has(document.uri.toString())) { - return next(document, position, token); + void sendMessage(document); } - return null; - }), - provideSignatureHelp: invoke4, - provideDefinition: invoke3, - provideReferences: invoke4, - provideDocumentHighlights: invoke3, - provideDeclaration: invoke3, - workspace: { - didChangeConfiguration: invoke1 } }; }