1
1
import { inject , injectable } from 'inversify' ;
2
2
import { remote } from 'electron' ;
3
3
import { ArduinoMenus } from '../menu/arduino-menus' ;
4
- import { SketchContribution , Command , CommandRegistry , MenuModelRegistry , KeybindingRegistry , URI , Sketch } from './contribution' ;
4
+ import { SketchContribution , Command , CommandRegistry , MenuModelRegistry , KeybindingRegistry , URI } from './contribution' ;
5
5
import { SaveAsSketch } from './save-as-sketch' ;
6
6
import { EditorManager } from '@theia/editor/lib/browser' ;
7
7
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor' ;
@@ -20,7 +20,11 @@ export class CloseSketch extends SketchContribution {
20
20
return ;
21
21
}
22
22
const isTemp = await this . sketchService . isTemp ( sketch ) ;
23
- if ( isTemp && await this . wasTouched ( sketch ) ) {
23
+ const uri = await this . currentSketchFile ( ) ;
24
+ if ( ! uri ) {
25
+ return ;
26
+ }
27
+ if ( isTemp && await this . wasTouched ( uri ) ) {
24
28
const { response } = await remote . dialog . showMessageBox ( {
25
29
type : 'question' ,
26
30
buttons : [ "Don't Save" , 'Cancel' , 'Save' ] ,
@@ -60,8 +64,8 @@ export class CloseSketch extends SketchContribution {
60
64
/**
61
65
* If the file was ever touched/modified. We get this based on the `version` of the monaco model.
62
66
*/
63
- protected async wasTouched ( sketch : Sketch ) : Promise < boolean > {
64
- const editorWidget = await this . editorManager . getByUri ( new URI ( sketch . uri ) . resolve ( ` ${ sketch . name } .ino` ) ) ;
67
+ protected async wasTouched ( uri : string ) : Promise < boolean > {
68
+ const editorWidget = await this . editorManager . getByUri ( new URI ( uri ) ) ;
65
69
if ( editorWidget ) {
66
70
const { editor } = editorWidget ;
67
71
if ( editor instanceof MonacoEditor ) {
0 commit comments