@@ -19,7 +19,10 @@ import {
19
19
} from './contribution' ;
20
20
import { ArduinoMenus , PlaceholderMenuNode } from '../menu/arduino-menus' ;
21
21
import { EditorManager } from '@theia/editor/lib/browser/editor-manager' ;
22
- import { SketchesServiceClientImpl } from '../../common/protocol/sketches-service-client-impl' ;
22
+ import {
23
+ CurrentSketch ,
24
+ SketchesServiceClientImpl ,
25
+ } from '../../common/protocol/sketches-service-client-impl' ;
23
26
import { LocalCacheFsProvider } from '../local-cache/local-cache-fs-provider' ;
24
27
import { nls } from '@theia/core/lib/common' ;
25
28
@@ -55,7 +58,7 @@ export class SketchControl extends SketchContribution {
55
58
execute : async ( ) => {
56
59
this . toDisposeBeforeCreateNewContextMenu . dispose ( ) ;
57
60
const sketch = await this . sketchServiceClient . currentSketch ( ) ;
58
- if ( ! sketch ) {
61
+ if ( ! CurrentSketch . isValid ( sketch ) ) {
59
62
return ;
60
63
}
61
64
@@ -70,25 +73,22 @@ export class SketchControl extends SketchContribution {
70
73
return ;
71
74
}
72
75
73
- const { mainFileUri, rootFolderFileUris } =
74
- await this . sketchService . loadSketch ( sketch . uri ) ;
76
+ const { mainFileUri, rootFolderFileUris } = sketch ;
75
77
const uris = [ mainFileUri , ...rootFolderFileUris ] ;
76
78
77
- const currentSketch =
78
- await this . sketchesServiceClient . currentSketch ( ) ;
79
- const parentsketchUri = this . editorManager . currentEditor
79
+ const parentSketchUri = this . editorManager . currentEditor
80
80
?. getResourceUri ( )
81
81
?. toString ( ) ;
82
- const parentsketch = await this . sketchService . getSketchFolder (
83
- parentsketchUri || ''
82
+ const parentSketch = await this . sketchService . getSketchFolder (
83
+ parentSketchUri || ''
84
84
) ;
85
85
86
86
// if the current file is in the current opened sketch, show extra menus
87
87
if (
88
- currentSketch &&
89
- parentsketch &&
90
- parentsketch . uri === currentSketch . uri &&
91
- this . allowRename ( parentsketch . uri )
88
+ sketch &&
89
+ parentSketch &&
90
+ parentSketch . uri === sketch . uri &&
91
+ this . allowRename ( parentSketch . uri )
92
92
) {
93
93
this . menuRegistry . registerMenuAction (
94
94
ArduinoMenus . SKETCH_CONTROL__CONTEXT__MAIN_GROUP ,
@@ -122,10 +122,10 @@ export class SketchControl extends SketchContribution {
122
122
}
123
123
124
124
if (
125
- currentSketch &&
126
- parentsketch &&
127
- parentsketch . uri === currentSketch . uri &&
128
- this . allowDelete ( parentsketch . uri )
125
+ sketch &&
126
+ parentSketch &&
127
+ parentSketch . uri === sketch . uri &&
128
+ this . allowDelete ( parentSketch . uri )
129
129
) {
130
130
this . menuRegistry . registerMenuAction (
131
131
ArduinoMenus . SKETCH_CONTROL__CONTEXT__MAIN_GROUP ,
0 commit comments