mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-24 18:36:44 -06:00
Dev Mode: Revert to saved is refused there (it throws unsaved design edits away)
This commit is contained in:
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user