git.lucas.co / cce-designer
graphic design tool
git clone https://git.lucas.co/cce-designer.git

commita7093826287356b5d8f112a730aa936b8f0842bd
parent41266d74fc
authorLucas Galante <lsgalante12@gmail.com>
date2026-09-29 18:11
fix: New Project from the palette starts a project

The new_project command dispatched the label "New Project", which
execute_menu_action had no arm for, so the palette row and Ctrl+N ran
and did nothing. The test meant to catch that scanned from the function
to the end of the file and found the label in the menubar's item list.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

 src/app.rs  |  4 ++++
 src/main.rs | 19 ++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/app.rs b/src/app.rs
index bfaba50..699adb2 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -3799,6 +3799,10 @@ impl State {
             "Set As Default" => {
                 self.set_current_as_default();
             }
+            "New Project" | "New" => {
+                self.new_project();
+                self.update_status_text("New project");
+            }
             "Open" => {
                 self.open_file_chooser();
             }
diff --git a/src/main.rs b/src/main.rs
index 80b7bb7..2e5e62f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6611,7 +6611,13 @@ mod tests {
         let start = src
             .find("pub fn execute_menu_action")
             .expect("execute_menu_action moved; this test scans for it");
-        let body = &src[start..];
+        // The function alone, not the rest of the file: the menubars are
+        // built further down with their items spelled out, and scanning on
+        // to the end found "New Project" THERE while no arm dispatched it.
+        let end = src[start..]
+            .find("\n    }\n")
+            .expect("execute_menu_action has no end");
+        let body = &src[start..start + end];
         for c in COMMANDS {
             let Run::Menu(label) = c.run else { continue };
             let arm = format!("\"{label}\"");
@@ -6623,6 +6629,17 @@ mod tests {
         }
     }
 
+    /// New Project from the palette starts a project. The command named a
+    /// label no arm dispatched, so the row ran and nothing happened.
+    #[test]
+    fn the_new_project_command_starts_an_empty_project() {
+        let mut state = State::new(false);
+        assert!(!state.fs_root.children.is_empty(), "the bundled project has nodes");
+        assert!(state.run_command("new_project"));
+        assert!(state.fs_root.children.is_empty(), "New Project left the old nodes in place");
+        assert_eq!(state.loaded_project_path, None);
+    }
+
     /// Two commands on one chord is silent at the keyboard — the second never
     /// runs and nothing says why — so it is reported at startup.
     #[test]