From 67a2938cab585f7d458fca46436c985dda173113 Mon Sep 17 00:00:00 2001 From: jonathnwxh <258340642+jonathanwxh-cell@users.noreply.github.com> Date: Thu, 15 Oct 2026 23:32:18 +0800 Subject: [PATCH] Guard intentional hidden selections against failures and unrelated edits --- crates/ui-egui/src/view_cmds/tests.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/ui-egui/src/view_cmds/tests.rs b/crates/ui-egui/src/view_cmds/tests.rs index 80ab177f0f..c966f516db 100644 --- a/crates/ui-egui/src/view_cmds/tests.rs +++ b/crates/ui-egui/src/view_cmds/tests.rs @@ -525,3 +525,17 @@ fn creating_a_selection_restores_hidden_extras() { } assert!(hidden.is_empty(), "new selections stayed hidden after Extras was disabled: {hidden:?}"); } + +#[test] +fn failed_selection_and_unrelated_edits_keep_extras_hidden() { + let (mut app, ctx) = app_with(1); + app.run("select.rect", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap(); + menu(&mut app, &ctx, "view.extras", json!({})).unwrap(); + assert!(!app.ui.view.extras); + assert!(app.run("select.rect", json!({"x": "invalid"})).is_err()); + assert!(!app.ui.view.extras, "failed selection must not change the view"); + app.run("edit.fill", json!({"color": "#cc4422"})).unwrap(); + assert!(!app.ui.view.extras, "painting an existing hidden selection keeps it hidden"); + app.run("select.deselect", json!({})).unwrap(); + assert!(!app.ui.view.extras, "deselecting has no new outline to reveal"); +}