mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-06-17 17:46:33 +00:00
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
This commit is contained in:
parent
3b04d8df26
commit
437caeb348
@ -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<void> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ void loop() {
|
||||
|
||||
async isTemp(sketch: Sketch): Promise<boolean> {
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user