Skip to content

Commit 7abfa53

Browse files
committed
Align CLOSE command to rest of app
1 parent 1c82e25 commit 7abfa53

File tree

1 file changed

+1
-72
lines changed
  • arduino-ide-extension/src/browser/contributions

1 file changed

+1
-72
lines changed

arduino-ide-extension/src/browser/contributions/close.ts

+1-72
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { inject, injectable } from '@theia/core/shared/inversify';
2-
import { toArray } from '@theia/core/shared/@phosphor/algorithm';
32
import * as remote from '@theia/core/electron-shared/@electron/remote';
43
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
54
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
65
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
76
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
87
import { ArduinoMenus } from '../menu/arduino-menus';
9-
import { SaveAsSketch } from './save-as-sketch';
108
import {
119
SketchContribution,
1210
Command,
@@ -33,76 +31,7 @@ export class Close extends SketchContribution {
3331

3432
registerCommands(registry: CommandRegistry): void {
3533
registry.registerCommand(Close.Commands.CLOSE, {
36-
execute: async () => {
37-
// Close current editor if closeable.
38-
const { currentEditor } = this.editorManager;
39-
if (currentEditor && currentEditor.title.closable) {
40-
currentEditor.close();
41-
return;
42-
}
43-
44-
// Close current widget from the main area if possible.
45-
const { currentWidget } = this.shell;
46-
if (currentWidget) {
47-
const currentWidgetInMain = toArray(
48-
this.shell.mainPanel.widgets()
49-
).find((widget) => widget === currentWidget);
50-
if (currentWidgetInMain && currentWidgetInMain.title.closable) {
51-
return currentWidgetInMain.close();
52-
}
53-
}
54-
55-
// Close the sketch (window).
56-
const sketch = await this.sketchServiceClient.currentSketch();
57-
if (!sketch) {
58-
return;
59-
}
60-
const isTemp = await this.sketchService.isTemp(sketch);
61-
const uri = await this.sketchServiceClient.currentSketchFile();
62-
if (!uri) {
63-
return;
64-
}
65-
if (isTemp && (await this.wasTouched(uri))) {
66-
const { response } = await remote.dialog.showMessageBox({
67-
type: 'question',
68-
buttons: [
69-
nls.localize(
70-
'vscode/abstractTaskService/saveBeforeRun.dontSave',
71-
"Don't Save"
72-
),
73-
nls.localize('vscode/issueMainService/cancel', 'Cancel'),
74-
nls.localize(
75-
'vscode/abstractTaskService/saveBeforeRun.save',
76-
'Save'
77-
),
78-
],
79-
message: nls.localize(
80-
'arduino/common/saveChangesToSketch',
81-
'Do you want to save changes to this sketch before closing?'
82-
),
83-
detail: nls.localize(
84-
'arduino/common/loseChanges',
85-
"If you don't save, your changes will be lost."
86-
),
87-
});
88-
if (response === 1) {
89-
// Cancel
90-
return;
91-
}
92-
if (response === 2) {
93-
// Save
94-
const saved = await this.commandService.executeCommand(
95-
SaveAsSketch.Commands.SAVE_AS_SKETCH.id,
96-
{ openAfterMove: false, execOnlyIfTemp: true }
97-
);
98-
if (!saved) {
99-
// If it was not saved, do bail the close.
100-
return;
101-
}
102-
}
103-
}
104-
window.close();
105-
},
34+
execute: () => remote.getCurrentWindow().close()
10635
});
10736
}
10837

0 commit comments

Comments
 (0)