Skip to content

Commit 5bd6801

Browse files
committed
SaveAs should preserve the folder structure if user selected a sketch
Fixes arduino#6416
1 parent fea9bd1 commit 5bd6801

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/src/processing/app/SketchController.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,14 @@ protected boolean saveAs() throws IOException {
379379
if (newName == null) return false;
380380
newName = SketchController.checkName(newName);
381381

382-
File newFolder = new File(newParentDir, newName);
382+
File newFolder;
383+
// User may want to overwrite a .ino
384+
// check if the parent folder name ends with the sketch name
385+
if (newName.endsWith(".ino") && newParentDir.endsWith(newName.substring(0, newName.lastIndexOf('.'))+ File.separator)) {
386+
newFolder = new File(newParentDir);
387+
} else {
388+
newFolder = new File(newParentDir, newName);
389+
}
383390

384391
// check if the paths are identical
385392
if (newFolder.equals(sketch.getFolder())) {

0 commit comments

Comments
 (0)