Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Commit cd22e4e

Browse files
authored
Merge pull request #46 from ironmansoftware/debuggerCommand
Debugger Command.
2 parents b03d89f + 20957c6 commit cd22e4e

4 files changed

Lines changed: 35 additions & 1 deletion

File tree

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,21 @@
268268
"command": "powershell-universal.editModule",
269269
"title": "Edit Module",
270270
"icon": "$(go-to-file)"
271+
},
272+
{
273+
"command": "powershell-universal.connectDebugger",
274+
"title": "Connect Debugger",
275+
"icon": "$(debug)"
276+
},
277+
{
278+
"command": "powershell-universal.connectDebugger",
279+
"title": "Connect Debugger",
280+
"icon": "$(debug)"
281+
},
282+
{
283+
"command": "powershell-universal.disconnectDebugger",
284+
"title": "Disconnect Debugger",
285+
"icon": "$(debug-disconnect)"
271286
}
272287
],
273288
"debuggers": [
@@ -447,6 +462,16 @@
447462
"command": "powershell-universal.reloadConfig",
448463
"when": "view == universalConfigProviderView",
449464
"group": "navigation"
465+
},
466+
{
467+
"command": "powershell-universal.connectDebugger",
468+
"when": "view == universalPlatformProviderView && !powershell-universal.debuggerConnected",
469+
"group": "navigation"
470+
},
471+
{
472+
"command": "powershell-universal.disconnectDebugger",
473+
"when": "view == universalPlatformProviderView && powershell-universal.debuggerConnected",
474+
"group": "navigation"
450475
}
451476
],
452477
"view/item/context": [

src/commands/debugger.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { Container } from '../container';
55

66
export const registerDebuggerCommands = (context: vscode.ExtensionContext) => {
77
vscode.commands.registerCommand('powershell-universal.attachRunspace', (item) => attachRunspace(item, context));
8+
vscode.commands.registerCommand('powershell-universal.connectDebugger', _ => Container.universal.connectDebugger());
9+
vscode.commands.registerCommand('powershell-universal.disconnectDebugger', _ => Container.universal.disconnectDebugger());
810

911
vscode.debug.registerDebugAdapterDescriptorFactory('powershelluniversal', {
1012
createDebugAdapterDescriptor: (_session) => {

src/extension.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export async function activate(context: vscode.ExtensionContext) {
117117

118118
if (Container.universal.hasConnection() && !localDevConfig) {
119119
if (await Container.universal.waitForAlive()) {
120-
await Container.universal.connectDebugger();
121120
await Container.universal.installAndLoadModule();
122121
}
123122
}

src/universal.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,12 @@ export class Universal {
718718
this.debugAdapter = undefined;
719719
}
720720

721+
disconnectDebugger() {
722+
if (this.hubConnection) {
723+
this.hubConnection.stop();
724+
}
725+
}
726+
721727
connectDebugger() {
722728
const settings = load();
723729

@@ -755,12 +761,14 @@ export class Universal {
755761

756762
this.hubConnection.onclose(() => {
757763
vscode.window.showInformationMessage("Disconnected from PowerShell Universal Debugger.");
764+
vscode.commands.executeCommand('setContext', 'powershell-universal.debuggerConnected', false);
758765
});
759766

760767
this.hubConnection.start().then(() => {
761768
this.hubConnection?.invoke("connect").then((msg) => {
762769
if (msg.success) {
763770
vscode.window.showInformationMessage(msg.message);
771+
vscode.commands.executeCommand('setContext', 'powershell-universal.debuggerConnected', true);
764772
} else {
765773
vscode.window.showErrorMessage(msg.message);
766774
}

0 commit comments

Comments
 (0)