Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 437caeb

Browse files
Open Save as... dialog when saving sketches for the first time (#579)
* Properly recognize temporary sketches in macOS Without this fix, sketches report their URI path as /private/var/xxx whereas `os.tmpdir()` returns /var/xxx. The second path can be turned into the first by resolving symlinks, which gives a canonical path to compare against. * Open Save as... dialog when saving sketches for the first time
1 parent 3b04d8d commit 437caeb

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

‎arduino-ide-extension/src/browser/contributions/save-sketch.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { injectable } from 'inversify';
22
import { CommonCommands } from '@theia/core/lib/browser/common-frontend-contribution';
33
import { ArduinoMenus } from '../menu/arduino-menus';
44
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
5+
import { SaveAsSketch } from './save-as-sketch';
56
import {
67
SketchContribution,
78
Command,
@@ -51,6 +52,22 @@ export class SaveSketch extends SketchContribution {
5152
}
5253

5354
async saveSketch(): Promise<void> {
55+
const sketch = await this.sketchServiceClient.currentSketch();
56+
if (!sketch) {
57+
return;
58+
}
59+
const isTemp = await this.sketchService.isTemp(sketch);
60+
if (isTemp) {
61+
return this.commandService.executeCommand(
62+
SaveAsSketch.Commands.SAVE_AS_SKETCH.id,
63+
{
64+
execOnlyIfTemp: false,
65+
openAfterMove: true,
66+
wipeOriginal: true,
67+
}
68+
);
69+
}
70+
5471
return this.commandService.executeCommand(CommonCommands.SAVE_ALL.id);
5572
}
5673
}

‎arduino-ide-extension/src/node/sketches-service-impl.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ void loop() {
387387

388388
async isTemp(sketch: Sketch): Promise<boolean> {
389389
let sketchPath = FileUri.fsPath(sketch.uri);
390-
let temp = os.tmpdir();
390+
let temp = awaitpromisify(fs.realpath)(os.tmpdir());
391391
// Note: VS Code URI normalizes the drive letter. `C:` will be converted into `c:`.
392392
// https://github.com/Microsoft/vscode/issues/68325#issuecomment-462239992
393393
if (isWindows) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /