1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-18 12:54:25 +01:00

SaveAs should preserve the folder structure if user selected a sketch

Fixes https://github.com/arduino/Arduino/issues/6416
This commit is contained in:
Martino Facchin 2017-12-11 11:33:16 +01:00
parent 7bef3d549b
commit 2be54da740

View File

@ -387,7 +387,14 @@ public class SketchController {
if (newName == null) return false;
newName = SketchController.checkName(newName);
File newFolder = new File(newParentDir, newName);
File newFolder;
// User may want to overwrite a .ino
// check if the parent folder name ends with the sketch name
if (newName.endsWith(".ino") && newParentDir.endsWith(newName.substring(0, newName.lastIndexOf('.'))+ File.separator)) {
newFolder = new File(newParentDir);
} else {
newFolder = new File(newParentDir, newName);
}
// check if the paths are identical
if (newFolder.equals(sketch.getFolder())) {