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
This commit is contained in:
Matt Bierner
2024-10-30 14:20:30 -07:00
committed by GitHub
parent 8875f03ec8
commit d83223b7c2
@@ -16,7 +16,7 @@ export class TSServerRequestCommand implements Command {
private readonly lazyClientHost: Lazy<TypeScriptServiceClientHost>
) { }
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);
}
}