From 62910d03279dfd980c2764c5b547bd6fb8dfa823 Mon Sep 17 00:00:00 2001 From: nrq6993-a11y Date: Mon, 19 Oct 2026 02:29:58 +0300 Subject: [PATCH] #2991: list Enter Isolation Mode in Keyboard Shortcuts Mark object.isolate id as optional so runs_without_params includes it in the shortcut editor; engine already isolates the first selected object when id is omitted. Co-authored-by: Cursor --- crates/engine/src/cmd/object.rs | 2 +- crates/engine/src/tests_menucmds.rs | 11 +++++++++++ crates/ui-egui/src/shortcut_editor.rs | 12 ++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/object.rs b/crates/engine/src/cmd/object.rs index d806d9c80..5ddf1ec32 100644 --- a/crates/engine/src/cmd/object.rs +++ b/crates/engine/src/cmd/object.rs @@ -227,7 +227,7 @@ pub fn specs() -> Vec { has_selection, |s, _| clip_edit(s, true) ), - cmd!("object.isolate", "Enter Isolation Mode", [], None, "{id}", has_doc, isolate), + cmd!("object.isolate", "Enter Isolation Mode", [], None, "{id?} (default: the selection's first object)", has_doc, isolate), cmd!("object.exitIsolation", "Exit Isolation Mode", [], None, "{}", has_doc, exit_isolation), cmd!( "object.setProps", diff --git a/crates/engine/src/tests_menucmds.rs b/crates/engine/src/tests_menucmds.rs index 8b93e5532..1b888a2a7 100644 --- a/crates/engine/src/tests_menucmds.rs +++ b/crates/engine/src/tests_menucmds.rs @@ -1280,6 +1280,17 @@ fn next_object_above_and_below_pass_over_what_cant_be_selected() { assert_eq!(selected(&s), vec![a]); } +/// A keyboard shortcut runs `object.isolate` with no params; the first selected object is isolated (#2991). +#[test] +fn object_isolate_without_id_uses_the_selection() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 50.0, 50.0); + let _b = rect(&mut s, 100.0, 0.0, 50.0, 50.0); + sel(&mut s, &[a]); + s.execute("object.isolate", &json!({})).unwrap(); + assert_eq!(s.doc().unwrap().isolation, Some(a)); +} + /// In isolation mode Select › Same and Select › Object select only objects in the isolated group. #[test] fn select_menu_commands_stay_inside_the_isolated_group() { diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index 9d0b3aea6..7773428e0 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -1014,4 +1014,16 @@ mod tests { assert!(assign(&mut ov, "symbol.breakLink", Some("Cmd+Alt+Shift+F9"), true).is_ok()); assert_eq!(effective_in(&ov, "symbol.breakLink").as_deref(), Some("Cmd+Alt+Shift+F9")); } + + /// #2991: Enter Isolation Mode has no default key but runs on the selection, so it belongs in + /// Edit › Keyboard Shortcuts. + #[test] + fn enter_isolation_mode_command_is_listed_and_assignable() { + let e = entry("object.isolate").expect("listed"); + assert_eq!((e.label.as_str(), e.group.as_str(), e.is_tool), ("Enter Isolation Mode", "Object", false)); + assert_eq!(default_of("object.isolate"), None); + let mut ov = BTreeMap::new(); + assign(&mut ov, "object.isolate", Some("Cmd+Alt+Shift+F11"), false).unwrap(); + assert_eq!(effective_in(&ov, "object.isolate").as_deref(), Some("Cmd+Alt+Shift+F11")); + } }