diff --git a/arduino-ide-extension/src/browser/contributions/save-sketch.ts b/arduino-ide-extension/src/browser/contributions/save-sketch.ts index 0d95c36b0..a9f578632 100644 --- a/arduino-ide-extension/src/browser/contributions/save-sketch.ts +++ b/arduino-ide-extension/src/browser/contributions/save-sketch.ts @@ -2,6 +2,7 @@ import { injectable } from 'inversify'; import { CommonCommands } from '@theia/core/lib/browser/common-frontend-contribution'; import { ArduinoMenus } from '../menu/arduino-menus'; import { ArduinoToolbar } from '../toolbar/arduino-toolbar'; +import { SaveAsSketch } from './save-as-sketch'; import { SketchContribution, Command, @@ -51,6 +52,22 @@ export class SaveSketch extends SketchContribution { } async saveSketch(): Promise { + const sketch = await this.sketchServiceClient.currentSketch(); + if (!sketch) { + return; + } + const isTemp = await this.sketchService.isTemp(sketch); + if (isTemp) { + return this.commandService.executeCommand( + SaveAsSketch.Commands.SAVE_AS_SKETCH.id, + { + execOnlyIfTemp: false, + openAfterMove: true, + wipeOriginal: true, + } + ); + } + return this.commandService.executeCommand(CommonCommands.SAVE_ALL.id); } } diff --git a/arduino-ide-extension/src/node/sketches-service-impl.ts b/arduino-ide-extension/src/node/sketches-service-impl.ts index 02280050d..f16cc7f91 100644 --- a/arduino-ide-extension/src/node/sketches-service-impl.ts +++ b/arduino-ide-extension/src/node/sketches-service-impl.ts @@ -387,7 +387,7 @@ void loop() { async isTemp(sketch: Sketch): Promise { let sketchPath = FileUri.fsPath(sketch.uri); - let temp = os.tmpdir(); + let temp = await promisify(fs.realpath)(os.tmpdir()); // Note: VS Code URI normalizes the drive letter. `C:` will be converted into `c:`. // https://github.com/Microsoft/vscode/issues/68325#issuecomment-462239992 if (isWindows) {