Skip to content

Commit e2aeecd

Browse files
committed
Address PR comments, change to single promptClean up debug configuration snippet names & descriptions.Remove Launch Pester Tests debug config snippet. The Launch Scriptsnippet gives an example of invoking Pester plus we have code lens todebug Pester tests.
1 parent 1352177 commit e2aeecd

File tree

2 files changed

+69
-91
lines changed

2 files changed

+69
-91
lines changed

package.json

+11-25
Original file line numberDiff line numberDiff line change
@@ -330,19 +330,18 @@
330330
"configurationSnippets": [
331331
{
332332
"label": "PowerShell: Launch Current File",
333-
"description": "Launch current file (in active editor window) under debugger",
333+
"description": "Launch and debug the file in the currently active editor window",
334334
"body": {
335335
"name": "PowerShell Launch Current File",
336336
"type": "PowerShell",
337337
"request": "launch",
338338
"script": "^\"\\${file}\"",
339-
"args": [],
340339
"cwd": "^\"\\${file}\""
341340
}
342341
},
343342
{
344343
"label": "PowerShell: Launch Current File w/Args Prompt",
345-
"description": "Launch current file (in active editor window) under debugger, prompting first for script arguments",
344+
"description": "Launch and debug the file in the currently active editor window, prompting first for arguments",
346345
"body": {
347346
"name": "PowerShell Launch Current File w/Args Prompt",
348347
"type": "PowerShell",
@@ -356,48 +355,35 @@
356355
},
357356
{
358357
"label": "PowerShell: Launch Script",
359-
"description": "Launch specified script or path to script under debugger",
358+
"description": "Launch and debug the specified file or command",
360359
"body": {
361-
"name": "PowerShell Launch ${Script}",
360+
"name": "PowerShell Launch Script",
362361
"type": "PowerShell",
363362
"request": "launch",
364-
"script": "^\"\\${workspaceFolder}/${Script}\"",
365-
"args": [],
363+
"script": "^\"enter path or command to execute e.g.: \\${workspaceFolder}/src/foo.ps1 or Invoke-Pester\"",
366364
"cwd": "^\"\\${workspaceFolder}\""
367365
}
368366
},
369367
{
370-
"label": "PowerShell: Pester Tests",
371-
"description": "Invokes Pester tests under debugger",
368+
"label": "PowerShell: Interactive Session",
369+
"description": "Debug commands executed from the Integrated Console",
372370
"body": {
373-
"name": "PowerShell Pester Tests",
371+
"name": "PowerShell Interactive Session",
374372
"type": "PowerShell",
375373
"request": "launch",
376-
"script": "Invoke-Pester",
377-
"args": [],
378-
"cwd": "^\"\\${workspaceFolder}\""
374+
"cwd": ""
379375
}
380376
},
381377
{
382378
"label": "PowerShell: Attach to PowerShell Host Process",
383-
"description": "Open host process picker to select process to attach debugger to",
379+
"description": "Attach the debugger to a running PowerShell Host Process",
384380
"body": {
385381
"name": "PowerShell Attach to Host Process",
386382
"type": "PowerShell",
387383
"request": "attach",
388384
"runspaceId": 1
389385
}
390386
},
391-
{
392-
"label": "PowerShell: Interactive Session",
393-
"description": "Start interactive session (Debug Console) under debugger",
394-
"body": {
395-
"name": "PowerShell Interactive Session",
396-
"type": "PowerShell",
397-
"request": "launch",
398-
"cwd": ""
399-
}
400-
},
401387
{
402388
"label": "PowerShell: Attach Interactive Session Runspace",
403389
"description": "Open runspace picker to select runspace to attach debugger to",
@@ -418,7 +404,7 @@
418404
},
419405
"args": {
420406
"type": "array",
421-
"description": "Command line arguments to pass to the PowerShell script. Specify ${command:SpecifyScriptArgs} if you want to be prompted for the args.",
407+
"description": "Command line arguments to pass to the PowerShell script. Specify \"${command:SpecifyScriptArgs}\" if you want to be prompted for the args.",
422408
"items": {
423409
"type": "string"
424410
},

src/features/DebugSession.ts

+58-66
Original file line numberDiff line numberDiff line change
@@ -47,82 +47,74 @@ export class DebugSessionFeature implements IFeature, DebugConfigurationProvider
4747
folder: WorkspaceFolder | undefined,
4848
token?: CancellationToken): Promise<DebugConfiguration[]> {
4949

50-
const launchAttachItems = [
51-
{ label: "Launch",
52-
description: "Launch the debugger with a specified script or for the interactive session" },
53-
{ label: "Attach",
54-
description: "Attach the debugger to a running PowerShell Host Process" },
50+
const launchCurrentFileLabel = "Launch Current File";
51+
const launchScriptLabel = "Launch Script";
52+
const interactiveSessionLabel = "Interactive Session";
53+
54+
const debugConfigPickItems = [
55+
{
56+
label: launchCurrentFileLabel,
57+
description: "Launch and debug the file in the currently active editor window",
58+
},
59+
{
60+
label: launchScriptLabel,
61+
description: "Launch and debug the specified file or command",
62+
},
63+
{
64+
label: interactiveSessionLabel,
65+
description: "Debug commands executed from the Integrated Console",
66+
},
67+
{
68+
label: "Attach",
69+
description: "Attach the debugger to a running PowerShell Host Process",
70+
},
5571
];
5672

57-
const debugTypeSelection =
73+
const launchSelection =
5874
await vscode.window.showQuickPick(
59-
launchAttachItems,
60-
{ placeHolder: "Would you like to launch or attach the PowerShell debugger?" });
61-
62-
let debugConfiguration = [];
63-
64-
if (debugTypeSelection.label === "Launch") {
65-
const launchCurrentFileLabel = "Launch Current File";
66-
const launchScriptLabel = "Launch Script";
67-
const interactiveSessionLabel = "Interactive Session";
68-
69-
const launchItems = [
70-
{ label: launchCurrentFileLabel,
71-
description: "Debugs whichever script is in the active editor window" },
72-
{ label: launchScriptLabel,
73-
description: "Debugs the specified script" },
74-
{ label: interactiveSessionLabel,
75-
description: "Debugs scripts or modules executed from the Integrated Console" },
76-
];
75+
debugConfigPickItems,
76+
{ placeHolder: "Select a PowerShell debug configuration" });
7777

78-
const launchSelection =
79-
await vscode.window.showQuickPick(
80-
launchItems,
81-
{ placeHolder: "Select a launch option" });
82-
83-
if (launchSelection.label === launchCurrentFileLabel) {
84-
debugConfiguration = [
85-
{
86-
name: "PowerShell: Launch Current File",
87-
type: "PowerShell",
88-
request: "launch",
89-
script: "${file}",
90-
cwd: "${file}",
91-
},
92-
];
93-
} else if (launchSelection.label === launchScriptLabel) {
94-
debugConfiguration = [
95-
{
96-
name: "PowerShell: Launch Script",
97-
type: "PowerShell",
98-
request: "launch",
99-
script: "enter path or script to execute e.g.: ${workspaceFolder}/src/foo.ps1 or Invoke-Pester",
100-
cwd: "${workspaceFolder}",
101-
},
102-
];
103-
} else {
104-
debugConfiguration = [
105-
{
106-
name: "PowerShell: Interactive Session",
107-
type: "PowerShell",
108-
request: "launch",
109-
cwd: "",
110-
},
111-
];
112-
}
113-
} else {
114-
// Return the "Attach to PowerShell Host Process" debug configuration
115-
debugConfiguration = [
78+
if (launchSelection.label === launchCurrentFileLabel) {
79+
return [
80+
{
81+
name: "PowerShell: Launch Current File",
82+
type: "PowerShell",
83+
request: "launch",
84+
script: "${file}",
85+
cwd: "${file}",
86+
},
87+
];
88+
} else if (launchSelection.label === launchScriptLabel) {
89+
return [
90+
{
91+
name: "PowerShell: Launch Script",
92+
type: "PowerShell",
93+
request: "launch",
94+
script: "enter path or command to execute e.g.: ${workspaceFolder}/src/foo.ps1 or Invoke-Pester",
95+
cwd: "${workspaceFolder}",
96+
},
97+
];
98+
} else if (launchSelection.label === interactiveSessionLabel) {
99+
return [
116100
{
117-
name: "PowerShell: Attach to PowerShell Host Process",
101+
name: "PowerShell: Interactive Session",
118102
type: "PowerShell",
119-
request: "attach",
120-
runspaceId: 1,
103+
request: "launch",
104+
cwd: "",
121105
},
122106
];
123107
}
124108

125-
return debugConfiguration;
109+
// Return the "Attach to PowerShell Host Process" debug configuration
110+
return [
111+
{
112+
name: "PowerShell: Attach to PowerShell Host Process",
113+
type: "PowerShell",
114+
request: "attach",
115+
runspaceId: 1,
116+
},
117+
];
126118
}
127119

128120
// DebugConfigurationProvider method

0 commit comments

Comments
 (0)