Skip to content

Commit 05abf28

Browse files
author
Akos Kitta
committed
No save dialog prompt if closing untouched sketch.
Signed-off-by: Akos Kitta <[email protected]>
1 parent 706fb46 commit 05abf28

File tree

1 file changed

+12
-2
lines changed
  • arduino-ide-extension/src/browser/contributions

1 file changed

+12
-2
lines changed

Diff for: arduino-ide-extension/src/browser/contributions/close.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
CommandRegistry,
99
MenuModelRegistry,
1010
KeybindingRegistry,
11+
Sketch,
1112
URI,
1213
} from './contribution';
1314
import { nls } from '@theia/core/lib/common';
@@ -47,12 +48,12 @@ export class Close extends SketchContribution {
4748
return {
4849
reason: 'temp-sketch',
4950
action: () => {
50-
return this.showTempSketchDialog();
51+
return this.showSaveTempSketchDialog();
5152
},
5253
};
5354
}
5455

55-
private async showTempSketchDialog(): Promise<boolean> {
56+
private async showSaveTempSketchDialog(): Promise<boolean> {
5657
const sketch = await this.sketchServiceClient.currentSketch();
5758
if (!CurrentSketch.isValid(sketch)) {
5859
return true;
@@ -61,6 +62,15 @@ export class Close extends SketchContribution {
6162
if (!isTemp) {
6263
return true;
6364
}
65+
66+
// If non of the sketch files were ever touched, do not prompt the save dialog. (#1274)
67+
const wereTouched = await Promise.all(
68+
Sketch.uris(sketch).map((uri) => this.wasTouched(uri))
69+
);
70+
if (wereTouched.every((wasTouched) => !Boolean(wasTouched))) {
71+
return true;
72+
}
73+
6474
const messageBoxResult = await remote.dialog.showMessageBox(
6575
remote.getCurrentWindow(),
6676
{

0 commit comments

Comments
 (0)