File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -168,10 +168,14 @@ export interface StatusBarMessageDetails {
168
168
message : string ;
169
169
timeout ?: number ;
170
170
}
171
+ interface InvokeRegisteredEditorCommandParameter {
172
+ commandName : string
173
+ }
171
174
172
175
export class ExtensionCommandsFeature implements IFeature {
173
176
174
177
private command : vscode . Disposable ;
178
+ private command2 : vscode . Disposable ;
175
179
private languageClient : LanguageClient ;
176
180
private extensionCommands : ExtensionCommand [ ] = [ ] ;
177
181
@@ -191,6 +195,21 @@ export class ExtensionCommandsFeature implements IFeature {
191
195
192
196
this . showExtensionCommands ( this . languageClient ) ;
193
197
} ) ;
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
+
194
213
}
195
214
196
215
public setLanguageClient ( languageclient : LanguageClient ) {
@@ -248,6 +267,7 @@ export class ExtensionCommandsFeature implements IFeature {
248
267
249
268
public dispose ( ) {
250
269
this . command . dispose ( ) ;
270
+ this . command2 . dispose ( ) ;
251
271
}
252
272
253
273
private addExtensionCommand ( command : ExtensionCommandAddedNotificationBody ) {
You can’t perform that action at this time.
0 commit comments