@@ -21,8 +21,15 @@ export function activateDebug(_: vscode.ExtensionContext): vscode.Disposable {
2121 vscode . commands . registerCommand (
2222 'arduino.debug.start' ,
2323 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+ }
2633 }
2734 ) ,
2835 vscode . commands . registerCommand (
@@ -60,6 +67,10 @@ export interface StartDebugParams {
6067 * Programmer for the debugging.
6168 */
6269 readonly programmer ?: string ;
70+ /**
71+ * Custom progress message to use when getting the debug information from the CLI.
72+ */
73+ readonly message ?: string ;
6374}
6475export type StartDebugResult = boolean ;
6576
@@ -124,6 +135,8 @@ async function startDebug(
124135 return vscode . debug . startDebugging ( undefined , launchConfig ) ;
125136}
126137
138+ const getDebugInfoMessage = 'Getting debug info...' ;
139+
127140async function createLaunchConfig (
128141 params : StartDebugParams
129142) : Promise < ArduinoDebugLaunchConfig > {
@@ -133,7 +146,10 @@ async function createLaunchConfig(
133146 }
134147 const { file, args } = buildDebugInfoArgs ( params ) ;
135148 const [ stdout , customConfigs ] = await Promise . all ( [
136- exec ( file , args ) ,
149+ withProgress (
150+ ( ) => exec ( file , args ) ,
151+ params . message ? params . message : getDebugInfoMessage
152+ ) ,
137153 loadDebugCustomJson ( params ) ,
138154 ] ) ;
139155 const debugInfo = await parseRawDebugInfo ( stdout ) ;
@@ -151,6 +167,23 @@ async function createLaunchConfig(
151167 return launchConfig ;
152168}
153169
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+
154187async function parseRawDebugInfo (
155188 raw : string
156189) : Promise < ( DebugInfo & Executable ) | undefined > {
0 commit comments