@@ -21,8 +21,15 @@ export function activateDebug(_: vscode.ExtensionContext): vscode.Disposable {
21
21
vscode . commands . registerCommand (
22
22
'arduino.debug.start' ,
23
23
async ( params : StartDebugParams ) => {
24
- const launchConfig = await createLaunchConfig ( params ) ;
25
- return startDebug ( params . launchConfigsDirPath , launchConfig ) ;
24
+ try {
25
+ const launchConfig = await createLaunchConfig ( params ) ;
26
+ return startDebug ( params . launchConfigsDirPath , launchConfig ) ;
27
+ } catch ( err ) {
28
+ if ( err instanceof vscode . CancellationError ) {
29
+ return ;
30
+ }
31
+ throw err ;
32
+ }
26
33
}
27
34
) ,
28
35
vscode . commands . registerCommand (
@@ -60,6 +67,10 @@ export interface StartDebugParams {
60
67
* Programmer for the debugging.
61
68
*/
62
69
readonly programmer ?: string ;
70
+ /**
71
+ * Custom progress message to use when getting the debug information from the CLI.
72
+ */
73
+ readonly message ?: string ;
63
74
}
64
75
export type StartDebugResult = boolean ;
65
76
@@ -124,6 +135,8 @@ async function startDebug(
124
135
return vscode . debug . startDebugging ( undefined , launchConfig ) ;
125
136
}
126
137
138
+ const getDebugInfoMessage = 'Getting debug info...' ;
139
+
127
140
async function createLaunchConfig (
128
141
params : StartDebugParams
129
142
) : Promise < ArduinoDebugLaunchConfig > {
@@ -133,7 +146,10 @@ async function createLaunchConfig(
133
146
}
134
147
const { file, args } = buildDebugInfoArgs ( params ) ;
135
148
const [ stdout , customConfigs ] = await Promise . all ( [
136
- exec ( file , args ) ,
149
+ withProgress (
150
+ ( ) => exec ( file , args ) ,
151
+ params . message ? params . message : getDebugInfoMessage
152
+ ) ,
137
153
loadDebugCustomJson ( params ) ,
138
154
] ) ;
139
155
const debugInfo = await parseRawDebugInfo ( stdout ) ;
@@ -151,6 +167,23 @@ async function createLaunchConfig(
151
167
return launchConfig ;
152
168
}
153
169
170
+ async function withProgress < T > (
171
+ task : ( ) => Promise < T > | T ,
172
+ message : string
173
+ ) : Promise < T > {
174
+ return vscode . window . withProgress (
175
+ { location : vscode . ProgressLocation . Window } ,
176
+ async ( progress , token ) => {
177
+ if ( token . isCancellationRequested ) {
178
+ throw new vscode . CancellationError ( ) ;
179
+ }
180
+ progress . report ( { message } ) ;
181
+ const result = await task ( ) ;
182
+ return result as T ;
183
+ }
184
+ ) ;
185
+ }
186
+
154
187
async function parseRawDebugInfo (
155
188
raw : string
156
189
) : Promise < ( DebugInfo & Executable ) | undefined > {
0 commit comments