Skip to content

Commit 8c2a237

Browse files
committed
SaveAs should preserve the folder structure if user selected a sketch
Fixes #6416
1 parent c539f7a commit 8c2a237

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: app/src/processing/app/SketchController.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,14 @@ protected boolean saveAs() throws IOException {
391391
if (newName == null) return false;
392392
newName = SketchController.checkName(newName);
393393

394-
File newFolder = new File(newParentDir, newName);
394+
File newFolder;
395+
// User may want to overwrite a .ino
396+
// check if the parent folder name ends with the sketch name
397+
if (newName.endsWith(".ino") && newParentDir.endsWith(newName.substring(0, newName.lastIndexOf('.'))+ File.separator)) {
398+
newFolder = new File(newParentDir);
399+
} else {
400+
newFolder = new File(newParentDir, newName);
401+
}
395402

396403
// check if the paths are identical
397404
if (newFolder.equals(sketch.getFolder())) {

0 commit comments

Comments
 (0)