Skip to content

Commit fc5e82d

Browse files
kamilkosekdaviwil
authored andcommitted
Implement InvokeRegisteredEditorCommand
1 parent 37ede5e commit fc5e82d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/features/ExtensionCommands.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,14 @@ export interface StatusBarMessageDetails {
168168
message: string;
169169
timeout?: number;
170170
}
171+
interface InvokeRegisteredEditorCommandParameter{
172+
commandName : string
173+
}
171174

172175
export class ExtensionCommandsFeature implements IFeature {
173176

174177
private command: vscode.Disposable;
178+
private command2: vscode.Disposable;
175179
private languageClient: LanguageClient;
176180
private extensionCommands: ExtensionCommand[] = [];
177181

@@ -191,6 +195,21 @@ export class ExtensionCommandsFeature implements IFeature {
191195

192196
this.showExtensionCommands(this.languageClient);
193197
});
198+
this.command2 = vscode.commands.registerCommand('PowerShell.InvokeRegisteredEditorCommand',(param : InvokeRegisteredEditorCommandParameter) => {
199+
if(this.extensionCommands.length == 0){
200+
return;
201+
}
202+
203+
let commandToExecute = this.extensionCommands.find(x => x.name === param.commandName);
204+
205+
if(commandToExecute){
206+
this.languageClient.sendRequest(
207+
InvokeExtensionCommandRequest.type,
208+
{ name: commandToExecute.name,
209+
context: this.getEditorContext() });
210+
}
211+
});
212+
194213
}
195214

196215
public setLanguageClient(languageclient: LanguageClient) {
@@ -248,6 +267,7 @@ export class ExtensionCommandsFeature implements IFeature {
248267

249268
public dispose() {
250269
this.command.dispose();
270+
this.command2.dispose();
251271
}
252272

253273
private addExtensionCommand(command: ExtensionCommandAddedNotificationBody) {

0 commit comments

Comments
 (0)