From 3af6bc5963cccd303af6f2eb4b8c85acd4d363c7 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Thu, 16 Jan 2020 19:26:20 -0500 Subject: [PATCH] don't remove old sketch name from Recent menu on Save As --- app/src/processing/app/Sketch.java | 21 ++++++++++++++------- app/src/processing/app/ui/Recent.java | 3 +++ todo.txt | 3 +++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 7d3caf898..e686dc182 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -573,7 +573,7 @@ public class Sketch { code[i].setFolder(newFolder); } // Update internal state to reflect the new location - updateInternal(sanitaryName, newFolder); + updateInternal(sanitaryName, newFolder, renamingCode); // File newMainFile = new File(newFolder, newName + ".pde"); // String newMainFilePath = newMainFile.getAbsolutePath(); @@ -985,15 +985,17 @@ public class Sketch { // While the old path to the main .pde is still set, remove the entry from // the Recent menu so that it's not sticking around after the rename. // If untitled, it won't be in the menu, so there's no point. - if (!isUntitled()) { - Recent.remove(editor); - } +// if (!isUntitled()) { +// Recent.remove(editor); +// } + // Folks didn't like this behavior, so shutting it off + // https://github.com/processing/processing/issues/5902 // save the main tab with its new name File newFile = new File(newFolder, newName + "." + mode.getDefaultExtension()); code[0].saveAs(newFile); - updateInternal(newName, newFolder); + updateInternal(newName, newFolder, false); // Make sure that it's not an untitled sketch setUntitled(false); @@ -1191,7 +1193,8 @@ public class Sketch { /** * Update internal state for new sketch name or folder location. */ - protected void updateInternal(String sketchName, File sketchFolder) { + protected void updateInternal(String sketchName, File sketchFolder, + boolean renaming) { // reset all the state information for the sketch object String oldPath = getMainFilePath(); primaryFile = code[0].getFile(); @@ -1213,7 +1216,11 @@ public class Sketch { // System.out.println("modified is now " + modified); editor.updateTitle(); editor.getBase().rebuildSketchbookMenus(); - Recent.rename(editor, oldPath); + if (renaming) { + // only update the Recent menu if it's a rename, not a Save As + // https://github.com/processing/processing/issues/5902 + Recent.rename(editor, oldPath); + } // editor.header.rebuild(); } diff --git a/app/src/processing/app/ui/Recent.java b/app/src/processing/app/ui/Recent.java index 92f62ba7c..bc2676173 100644 --- a/app/src/processing/app/ui/Recent.java +++ b/app/src/processing/app/ui/Recent.java @@ -242,6 +242,8 @@ public class Recent { synchronized static public void remove(Editor editor) { int index = findRecord(editor.getSketch().getMainFilePath()); if (index != -1) { + System.out.println("removing " + editor.getSketch().getMainFilePath()); + new Exception().printStackTrace(System.out); records.remove(index); } } @@ -291,6 +293,7 @@ public class Recent { // If this sketch is already in the menu, remove it remove(editor); + // If the list is full, remove the first entry if (records.size() == Preferences.getInteger("recent.count")) { records.remove(0); // remove the first entry } diff --git a/todo.txt b/todo.txt index d9b9ee355..681bc2145 100755 --- a/todo.txt +++ b/todo.txt @@ -11,6 +11,9 @@ X don't unzip __MACOSX files with contribs X don't do library subfolders X show error when .properties file is missing from contribs X clean up a lot of bad temp file handling in the contrib manager +X https://github.com/processing/processing/issues/5845 +X don't remove entries from Recent menu on Save As +X https://github.com/processing/processing/issues/5902 after the JDK 11 update X use a new pref for the sketchbook folder location for 4.x