Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,21 @@
"command": "powershell-universal.editModule",
"title": "Edit Module",
"icon": "$(go-to-file)"
},
{
"command": "powershell-universal.connectDebugger",
"title": "Connect Debugger",
"icon": "$(debug)"
},
{
"command": "powershell-universal.connectDebugger",
"title": "Connect Debugger",
"icon": "$(debug)"
},
{
"command": "powershell-universal.disconnectDebugger",
"title": "Disconnect Debugger",
"icon": "$(debug-disconnect)"
}
],
"debuggers": [
Expand Down Expand Up @@ -447,6 +462,16 @@
"command": "powershell-universal.reloadConfig",
"when": "view == universalConfigProviderView",
"group": "navigation"
},
{
"command": "powershell-universal.connectDebugger",
"when": "view == universalPlatformProviderView && !powershell-universal.debuggerConnected",
"group": "navigation"
},
{
"command": "powershell-universal.disconnectDebugger",
"when": "view == universalPlatformProviderView && powershell-universal.debuggerConnected",
"group": "navigation"
}
],
"view/item/context": [
Expand Down
2 changes: 2 additions & 0 deletions src/commands/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Container } from '../container';

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

vscode.debug.registerDebugAdapterDescriptorFactory('powershelluniversal', {
createDebugAdapterDescriptor: (_session) => {
Expand Down
1 change: 0 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export async function activate(context: vscode.ExtensionContext) {

if (Container.universal.hasConnection() && !localDevConfig) {
if (await Container.universal.waitForAlive()) {
await Container.universal.connectDebugger();
await Container.universal.installAndLoadModule();
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,12 @@ export class Universal {
this.debugAdapter = undefined;
}

disconnectDebugger() {
if (this.hubConnection) {
this.hubConnection.stop();
}
}

connectDebugger() {
const settings = load();

Expand Down Expand Up @@ -755,12 +761,14 @@ export class Universal {

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

this.hubConnection.start().then(() => {
this.hubConnection?.invoke("connect").then((msg) => {
if (msg.success) {
vscode.window.showInformationMessage(msg.message);
vscode.commands.executeCommand('setContext', 'powershell-universal.debuggerConnected', true);
} else {
vscode.window.showErrorMessage(msg.message);
}
Expand Down