Skip to content

Commit 44d8f40

Browse files
authored
Fix duplicated command registrations (#3329)
Fixes #3320 by adding extension commands that call the built-in commands.
1 parent e476ee1 commit 44d8f40

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
"category": "PowerShell"
186186
},
187187
{
188-
"command": "workbench.action.debug.start",
188+
"command": "PowerShell.Debug.Start",
189189
"title": "Run",
190190
"category": "PowerShell",
191191
"icon": {
@@ -273,7 +273,7 @@
273273
"category": "PowerShell"
274274
},
275275
{
276-
"command": "workbench.action.closePanel",
276+
"command": "PowerShell.ClosePanel",
277277
"title": "Close panel",
278278
"category": "PowerShell",
279279
"icon": {
@@ -282,7 +282,7 @@
282282
}
283283
},
284284
{
285-
"command": "workbench.action.positionPanelLeft",
285+
"command": "PowerShell.PositionPanelLeft",
286286
"title": "Move panel left",
287287
"category": "PowerShell",
288288
"icon": {
@@ -291,7 +291,7 @@
291291
}
292292
},
293293
{
294-
"command": "workbench.action.positionPanelBottom",
294+
"command": "PowerShell.PositionPanelBottom",
295295
"title": "Move panel to bottom",
296296
"category": "PowerShell",
297297
"icon": {
@@ -355,22 +355,22 @@
355355
"editor/title": [
356356
{
357357
"when": "editorLangId == powershell && config.powershell.buttons.showPanelMovementButtons",
358-
"command": "workbench.action.positionPanelBottom",
358+
"command": "PowerShell.PositionPanelBottom",
359359
"group": "navigation@97"
360360
},
361361
{
362362
"when": "editorLangId == powershell && config.powershell.buttons.showPanelMovementButtons",
363-
"command": "workbench.action.positionPanelLeft",
363+
"command": "PowerShell.PositionPanelLeft",
364364
"group": "navigation@98"
365365
},
366366
{
367367
"when": "editorLangId == powershell && config.powershell.buttons.showPanelMovementButtons",
368-
"command": "workbench.action.closePanel",
368+
"command": "PowerShell.ClosePanel",
369369
"group": "navigation@99"
370370
},
371371
{
372372
"when": "editorLangId == powershell && config.powershell.buttons.showRunButtons",
373-
"command": "workbench.action.debug.start",
373+
"command": "PowerShell.Debug.Start",
374374
"group": "navigation@100"
375375
},
376376
{

src/features/ExtensionCommands.ts

+20
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ export class ExtensionCommandsFeature extends LanguageClientConsumer {
177177

178178
private command: vscode.Disposable;
179179
private command2: vscode.Disposable;
180+
private command3: vscode.Disposable;
181+
private command4: vscode.Disposable;
182+
private command5: vscode.Disposable;
183+
private command6: vscode.Disposable;
184+
// TODO: Make a list of commands instead.
180185
private extensionCommands: IExtensionCommand[] = [];
181186

182187
constructor(private log: Logger) {
@@ -209,6 +214,17 @@ export class ExtensionCommandsFeature extends LanguageClientConsumer {
209214
}
210215
});
211216

217+
this.command3 = vscode.commands.registerCommand('PowerShell.ClosePanel',
218+
async () => { await vscode.commands.executeCommand('workbench.action.closePanel'); }),
219+
220+
this.command4 = vscode.commands.registerCommand('PowerShell.PositionPanelLeft',
221+
async () => { await vscode.commands.executeCommand('workbench.action.positionPanelLeft'); }),
222+
223+
this.command5 = vscode.commands.registerCommand('PowerShell.PositionPanelBottom',
224+
async () => { await vscode.commands.executeCommand('workbench.action.positionPanelBottom'); }),
225+
226+
this.command6 = vscode.commands.registerCommand('PowerShell.Debug.Start',
227+
async () => { await vscode.commands.executeCommand('workbench.action.debug.start'); })
212228
}
213229

214230
public setLanguageClient(languageclient: LanguageClient) {
@@ -281,6 +297,10 @@ export class ExtensionCommandsFeature extends LanguageClientConsumer {
281297
public dispose() {
282298
this.command.dispose();
283299
this.command2.dispose();
300+
this.command3.dispose();
301+
this.command4.dispose();
302+
this.command5.dispose();
303+
this.command6.dispose();
284304
}
285305

286306
private addExtensionCommand(command: IExtensionCommandAddedNotificationBody) {

0 commit comments

Comments
 (0)