From e2000bbafce0c4440ec35bef100f6bca5d71d007 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 24 Oct 2026 02:35:15 +0700 Subject: [PATCH] Dev Mode: Revert to saved is refused there (it throws unsaved design edits away) --- crates/engine/src/devinspect.rs | 4 +++- crates/engine/src/devmode_behaviour_tests.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/devinspect.rs b/crates/engine/src/devinspect.rs index 7d93e974..16f4bbdc 100644 --- a/crates/engine/src/devinspect.rs +++ b/crates/engine/src/devinspect.rs @@ -220,11 +220,13 @@ pub struct DevItem { /// Whether Dev Mode runs command `id` from the menus and shortcuts: commands that don't edit the /// document, and Dev Mode's own edits (annotations, statuses, dev resources, code connections, -/// comments). Choosing a tool other than moving around and commenting is refused too. +/// comments). Choosing a tool other than moving around and commenting is refused too, and so is +/// Revert to saved, which isn't an undo step but throws the design's unsaved edits away. pub fn dev_mode_allows(id: &str) -> bool { const OWN: [&str; 5] = ["annotation.", "dev.", "devResource.", "codeConnect.", "comment."]; match id.strip_prefix("tool.") { Some(t) => matches!(t, "move" | "hand" | "comment"), + None if id == "file.revert" => false, None => OWN.iter().any(|p| id.starts_with(p)) || crate::cmd::find_command(id).is_none_or(|c| !c.history), } } diff --git a/crates/engine/src/devmode_behaviour_tests.rs b/crates/engine/src/devmode_behaviour_tests.rs index 32f50f3b..3d85fdb1 100644 --- a/crates/engine/src/devmode_behaviour_tests.rs +++ b/crates/engine/src/devmode_behaviour_tests.rs @@ -123,6 +123,7 @@ fn dev_mode_runs_its_own_edits_and_refuses_design_edits_from_menus_and_shortcuts "tool.text", "tool.place", "file.import", + "file.revert", ] { assert!(!dev_mode_allows(id), "{id} edits the design"); }