Skip to content

Commit 84acf46

Browse files
author
Federico Fissore
committed
Fix to save as to parent folder is needed by all OSs, not just Mac
1 parent 803a0ee commit 84acf46

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

app/src/processing/app/Sketch.java

+16-21
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,8 @@ protected boolean saveAs() throws IOException {
648648
} else {
649649
// default to the parent folder of where this was
650650
// on macs a .getParentFile() method is required
651-
652-
if (OSUtils.isMacOS()) {
653-
fd.setSelectedFile(data.getFolder().getParentFile());
654-
} else {
655-
fd.setSelectedFile(data.getFolder());
656-
}
657-
651+
652+
fd.setDirectory(data.getFolder().getParentFile().getAbsolutePath());
658653
}
659654
String oldName = data.getName();
660655
fd.setFile(oldName);
@@ -673,14 +668,13 @@ protected boolean saveAs() throws IOException {
673668
// but ignore this situation for the first tab, since it's probably being
674669
// resaved (with the same name) to another location/folder.
675670
for (SketchCode code : data.getCodes()) {
676-
if (newName.equalsIgnoreCase(code.getPrettyName()) &&
677-
code.isExtension("cpp")) {
671+
if (newName.equalsIgnoreCase(code.getPrettyName()) && code.isExtension("cpp")) {
678672
Base.showMessage(_("Nope"),
679-
I18n.format(
680-
_("You can't save the sketch as \"{0}\"\n" +
681-
"because the sketch already has a .cpp file with that name."),
682-
newName
683-
));
673+
I18n.format(
674+
_("You can't save the sketch as \"{0}\"\n" +
675+
"because the sketch already has a .cpp file with that name."),
676+
newName
677+
));
684678
return false;
685679
}
686680
}
@@ -699,11 +693,12 @@ protected boolean saveAs() throws IOException {
699693

700694
if (newPath.indexOf(oldPath) == 0) {
701695
Base.showWarning(_("How very Borges of you"),
702-
_("You cannot save the sketch into a folder\n" +
703-
"inside itself. This would go on forever."), null);
696+
_("You cannot save the sketch into a folder\n" +
697+
"inside itself. This would go on forever."), null);
704698
return false;
705699
}
706-
} catch (IOException e) { }
700+
} catch (IOException e) {
701+
}
707702

708703
// if the new folder already exists, then need to remove
709704
// its contents before copying everything over
@@ -755,10 +750,10 @@ protected boolean saveAs() throws IOException {
755750
data.getCode(0).saveAs(newFile);
756751

757752
editor.handleOpenUnchecked(newFile,
758-
currentIndex,
759-
editor.getSelectionStart(),
760-
editor.getSelectionStop(),
761-
editor.getScrollPosition());
753+
currentIndex,
754+
editor.getSelectionStart(),
755+
editor.getSelectionStop(),
756+
editor.getScrollPosition());
762757

763758
// Name changed, rebuild the sketch menus
764759
//editor.sketchbook.rebuildMenusAsync();

0 commit comments

Comments
 (0)