@@ -47,82 +47,74 @@ export class DebugSessionFeature implements IFeature, DebugConfigurationProvider
47
47
folder : WorkspaceFolder | undefined ,
48
48
token ?: CancellationToken ) : Promise < DebugConfiguration [ ] > {
49
49
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
+ } ,
55
71
] ;
56
72
57
- const debugTypeSelection =
73
+ const launchSelection =
58
74
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" } ) ;
77
77
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 [
116
100
{
117
- name : "PowerShell: Attach to PowerShell Host Process " ,
101
+ name : "PowerShell: Interactive Session " ,
118
102
type : "PowerShell" ,
119
- request : "attach " ,
120
- runspaceId : 1 ,
103
+ request : "launch " ,
104
+ cwd : "" ,
121
105
} ,
122
106
] ;
123
107
}
124
108
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
+ ] ;
126
118
}
127
119
128
120
// DebugConfigurationProvider method
0 commit comments