@@ -22,13 +22,16 @@ export class VerifySketch extends SketchContribution {
22
22
23
23
registerCommands ( registry : CommandRegistry ) : void {
24
24
registry . registerCommand ( VerifySketch . Commands . VERIFY_SKETCH , {
25
- execute : ( ) => this . verifySketch ( )
25
+ execute : ( ) => this . verifySketch ( ) ,
26
+ isEnabled : ( ) => ! this . verifyInProgress ,
26
27
} ) ;
27
28
registry . registerCommand ( VerifySketch . Commands . EXPORT_BINARIES , {
28
- execute : ( ) => this . verifySketch ( true )
29
+ execute : ( ) => this . verifySketch ( true ) ,
30
+ isEnabled : ( ) => ! this . verifyInProgress ,
29
31
} ) ;
30
32
registry . registerCommand ( VerifySketch . Commands . VERIFY_SKETCH_TOOLBAR , {
31
33
isVisible : widget => ArduinoToolbar . is ( widget ) && widget . side === 'left' ,
34
+ isEnabled : ( ) => ! this . verifyInProgress ,
32
35
isToggled : ( ) => this . verifyInProgress ,
33
36
execute : ( ) => registry . executeCommand ( VerifySketch . Commands . VERIFY_SKETCH . id )
34
37
} ) ;
@@ -69,10 +72,11 @@ export class VerifySketch extends SketchContribution {
69
72
70
73
async verifySketch ( exportBinaries ?: boolean ) : Promise < void > {
71
74
75
+ // toggle the toolbar button and menu item state.
76
+ // verifyInProgress will be set to false whether the compilation fails or not
72
77
this . verifyInProgress = true ;
73
78
const sketch = await this . sketchServiceClient . currentSketch ( ) ;
74
- this . verifyInProgress = false ;
75
-
79
+
76
80
if ( ! sketch ) {
77
81
return ;
78
82
}
@@ -97,6 +101,8 @@ export class VerifySketch extends SketchContribution {
97
101
this . messageService . info ( 'Done compiling.' , { timeout : 1000 } ) ;
98
102
} catch ( e ) {
99
103
this . messageService . error ( e . toString ( ) ) ;
104
+ } finally {
105
+ this . verifyInProgress = false ;
100
106
}
101
107
}
102
108
0 commit comments