mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Fix to save as to parent folder is needed by all OSs, not just Mac
This commit is contained in:
parent
803a0eebb4
commit
84acf463ec
@ -648,13 +648,8 @@ public class Sketch {
|
|||||||
} else {
|
} else {
|
||||||
// default to the parent folder of where this was
|
// default to the parent folder of where this was
|
||||||
// on macs a .getParentFile() method is required
|
// on macs a .getParentFile() method is required
|
||||||
|
|
||||||
if (OSUtils.isMacOS()) {
|
fd.setDirectory(data.getFolder().getParentFile().getAbsolutePath());
|
||||||
fd.setSelectedFile(data.getFolder().getParentFile());
|
|
||||||
} else {
|
|
||||||
fd.setSelectedFile(data.getFolder());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
String oldName = data.getName();
|
String oldName = data.getName();
|
||||||
fd.setFile(oldName);
|
fd.setFile(oldName);
|
||||||
@ -673,14 +668,13 @@ public class Sketch {
|
|||||||
// but ignore this situation for the first tab, since it's probably being
|
// but ignore this situation for the first tab, since it's probably being
|
||||||
// resaved (with the same name) to another location/folder.
|
// resaved (with the same name) to another location/folder.
|
||||||
for (SketchCode code : data.getCodes()) {
|
for (SketchCode code : data.getCodes()) {
|
||||||
if (newName.equalsIgnoreCase(code.getPrettyName()) &&
|
if (newName.equalsIgnoreCase(code.getPrettyName()) && code.isExtension("cpp")) {
|
||||||
code.isExtension("cpp")) {
|
|
||||||
Base.showMessage(_("Nope"),
|
Base.showMessage(_("Nope"),
|
||||||
I18n.format(
|
I18n.format(
|
||||||
_("You can't save the sketch as \"{0}\"\n" +
|
_("You can't save the sketch as \"{0}\"\n" +
|
||||||
"because the sketch already has a .cpp file with that name."),
|
"because the sketch already has a .cpp file with that name."),
|
||||||
newName
|
newName
|
||||||
));
|
));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -699,11 +693,12 @@ public class Sketch {
|
|||||||
|
|
||||||
if (newPath.indexOf(oldPath) == 0) {
|
if (newPath.indexOf(oldPath) == 0) {
|
||||||
Base.showWarning(_("How very Borges of you"),
|
Base.showWarning(_("How very Borges of you"),
|
||||||
_("You cannot save the sketch into a folder\n" +
|
_("You cannot save the sketch into a folder\n" +
|
||||||
"inside itself. This would go on forever."), null);
|
"inside itself. This would go on forever."), null);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (IOException e) { }
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
|
||||||
// if the new folder already exists, then need to remove
|
// if the new folder already exists, then need to remove
|
||||||
// its contents before copying everything over
|
// its contents before copying everything over
|
||||||
@ -755,10 +750,10 @@ public class Sketch {
|
|||||||
data.getCode(0).saveAs(newFile);
|
data.getCode(0).saveAs(newFile);
|
||||||
|
|
||||||
editor.handleOpenUnchecked(newFile,
|
editor.handleOpenUnchecked(newFile,
|
||||||
currentIndex,
|
currentIndex,
|
||||||
editor.getSelectionStart(),
|
editor.getSelectionStart(),
|
||||||
editor.getSelectionStop(),
|
editor.getSelectionStop(),
|
||||||
editor.getScrollPosition());
|
editor.getScrollPosition());
|
||||||
|
|
||||||
// Name changed, rebuild the sketch menus
|
// Name changed, rebuild the sketch menus
|
||||||
//editor.sketchbook.rebuildMenusAsync();
|
//editor.sketchbook.rebuildMenusAsync();
|
||||||
|
Loading…
Reference in New Issue
Block a user