From d0d934bfda252296c7d42dca165b0ea8e122c2b7 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 5 Oct 2026 22:43:28 +0700 Subject: [PATCH] M14.7: Cmd/Ctrl+N opens the New Document dialog The engine's file.new also claimed Cmd+N and engine commands win shortcut lookups, so the shortcut made a blank document. file.newDialog now owns it, as the docs already said; file.new stays the headless command. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/edit.rs | 2 +- crates/ui-egui/src/tests_home.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/edit.rs b/crates/engine/src/cmd/edit.rs index c230b009..fa58a619 100644 --- a/crates/engine/src/cmd/edit.rs +++ b/crates/engine/src/cmd/edit.rs @@ -17,7 +17,7 @@ pub fn specs() -> Vec { "file.new", "New…", ["File"], - Some("Cmd+N"), + None, "{preset?: a name from file.newPresets (start from it; the other params change it), name?|title?: document name (default Untitled-N), width?: pt=612|\"210 mm\", height?: pt=792, units?: \"Pixels\"|\"Points\"|\"Picas\"|\"Inches\"|\"Millimeters\"|\"Centimeters\"|\"Feet\"|\"Yards\"|\"Meters\"|\"Feet & Inches\" (default: prefs unitsGeneral, as print presets; screen presets: Pixels), orientation?: \"portrait\"|\"landscape\" (swaps width and height to match), artboards?: n (1–1000), artboardLayout?: {layout?: \"gridByRow\"|\"gridByColumn\"|\"row\"|\"column\", columns?: n (default: all in one row), spacing?: pt=20, rightToLeft?: bool}, bleed?: pt|[top, bottom, left, right]|{top?, …} (0–72 pt), backgroundContents?: \"transparent\"|\"white\" (a white artboard background, not an object), colorMode?: \"rgb\"|\"cmyk\" (a CMYK document starts with CMYK swatches and stores the colours applied to it as CMYK), rasterEffectsPpi?: 72|150|300 (1–2400), previewMode?: \"default\"|\"pixel\"|\"overprint\" (overprint turns Overprint Preview on, pixel Pixel Preview in the app; default leaves both), created?: Unix seconds|null (File Info's created date; default now, recorded in the journal so a replay matches)} → {index, previewMode}; the size is remembered in file.newPresets' Recent", always, super::newdoc::file_new diff --git a/crates/ui-egui/src/tests_home.rs b/crates/ui-egui/src/tests_home.rs index c3208f53..0fd8f0ca 100644 --- a/crates/ui-egui/src/tests_home.rs +++ b/crates/ui-egui/src/tests_home.rs @@ -1,4 +1,4 @@ -//! The Home icon shows the Home screen over open documents. +//! The Home icon shows the Home screen over open documents; Cmd+N opens the New Document dialog. use serde_json::json; @@ -38,3 +38,12 @@ fn home_shows_over_open_documents_until_a_document_is_chosen() { assert!(shows_document(&mut app)); assert!(app.ui.home.is_none()); } + +#[test] +fn cmd_n_opens_the_new_document_dialog() { + assert_eq!(crate::shortcut_editor::command_for_key("Cmd+N"), Some("file.newDialog")); + let mut app = app_with_doc(); + app.run("file.newDialog", json!({})).unwrap(); + assert_eq!(app.ui.dialog.as_ref().map(|d| d.kind.as_str()), Some("newDocument")); + assert_eq!(app.session.documents().len(), 1, "no document is made until the dialog's OK"); +}