Skip to content

Commit f7adc39

Browse files
committed
SaveAs should preserve the folder structure if user selected a sketch
Fixes arduino#6416
1 parent 9bdcba7 commit f7adc39

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
@@ -387,7 +387,14 @@ protected boolean saveAs() throws IOException {
387387
if (newName == null) return false;
388388
newName = SketchController.checkName(newName);
389389

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

392399
// check if the paths are identical
393400
if (newFolder.equals(sketch.getFolder())) {

0 commit comments

Comments
 (0)