From d83223b7c2071e4600bc2157041058f70192883f Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 30 Oct 2024 14:20:30 -0700 Subject: [PATCH] Try allowing custom commands to be sent to tsserver by extensions (#232663) For #218275 Limit this to commands that start with `_` which should indicate that it's a private command and prevent clashes with normal TS commands --- .../src/commands/tsserverRequests.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/extensions/typescript-language-features/src/commands/tsserverRequests.ts b/extensions/typescript-language-features/src/commands/tsserverRequests.ts index ba545dfbea9..9f79c1066c3 100644 --- a/extensions/typescript-language-features/src/commands/tsserverRequests.ts +++ b/extensions/typescript-language-features/src/commands/tsserverRequests.ts @@ -16,7 +16,7 @@ export class TSServerRequestCommand implements Command { private readonly lazyClientHost: Lazy ) { } - public execute(requestID: keyof TypeScriptRequests, args?: any, config?: any) { + public execute(command: keyof TypeScriptRequests, args?: any, config?: any) { // A cancellation token cannot be passed through the command infrastructure const token = nulToken; @@ -36,8 +36,11 @@ export class TSServerRequestCommand implements Command { 'completionInfo' ]; - if (!allowList.includes(requestID)) { return; } - return this.lazyClientHost.value.serviceClient.execute(requestID, args, token, config); + if (!allowList.includes(command) || command.startsWith('_')) { + return; + } + + return this.lazyClientHost.value.serviceClient.execute(command, args, token, config); } }