From 44950708baacb6a85e73a559c8cfdf69887d50f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9C=81=E4=BC=AA?= <56018602+r4x2t7@users.noreply.github.com> Date: Mon, 2 Nov 2026 07:23:09 +0800 Subject: [PATCH] TEXTEDIT: the context-menu test follows the window entry, several texts keep the command --- crates/ui-egui/src/context_menu.rs | 8 +------ crates/ui-egui/tests/it/context_menus.rs | 28 ++++++++++++++++++------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rs index 0b00d933c..3f1c98ebf 100644 --- a/crates/ui-egui/src/context_menu.rs +++ b/crates/ui-egui/src/context_menu.rs @@ -160,13 +160,7 @@ fn object_commands(app: &CadApp) -> Vec<(&'static str, Option<&'static str>)> { pub fn object_entries(app: &CadApp) -> Vec { object_commands(app) .into_iter() - .filter_map(|(id, label)| { - if id == "textedit" { - edit_text_window_entry(app).or_else(|| item(app, id, label)) - } else { - item(app, id, label) - } - }) + .filter_map(|(id, label)| if id == "textedit" { edit_text_window_entry(app).or_else(|| item(app, id, label)) } else { item(app, id, label) }) .collect() } diff --git a/crates/ui-egui/tests/it/context_menus.rs b/crates/ui-egui/tests/it/context_menus.rs index 3134b8d3c..fbd39f930 100644 --- a/crates/ui-egui/tests/it/context_menus.rs +++ b/crates/ui-egui/tests/it/context_menus.rs @@ -133,7 +133,8 @@ fn idle_menu_lists_recent_commands_and_selection_commands() { #[test] fn selection_menu_has_the_object_types_edit_commands() { let cases = [ - ("text", json!({ "at": [0, 0], "text": "hi" }), "textedit"), + // A single text's Edit Text opens the Edit Text window: the id carries the handle. + ("text", json!({ "at": [0, 0], "text": "hi" }), "textedit:"), ("pline", json!({ "vertices": [[0, 0], [10, 0], [10, 5]] }), "pedit"), ("spline", json!({ "fit": [[0, 0], [5, 5], [10, 0]] }), "splinedit"), ]; @@ -142,14 +143,27 @@ fn selection_menu_has_the_object_types_edit_commands() { app.run(cmd, params).unwrap(); select_all(&mut app); let g = vec![context_menu::object_entries(&app)]; - assert!(ids(&g).iter().any(|i| i == edit), "{cmd}: {edit} missing from {:?}", labels(&g)); - assert!(ids(&context_menu::entries(&app)).iter().any(|i| i == edit)); + let hit = ids(&g).iter().find(|i| i.starts_with(edit)).cloned(); + assert!(hit.is_some(), "{cmd}: {edit} missing from {:?}", labels(&g)); + assert!(ids(&context_menu::entries(&app)).iter().any(|i| i.starts_with(edit))); + // Choosing the window's entry opens the dialog on the object; the double-click keeps its + // in-place editing (#842). + if let Some(id) = hit.filter(|i| i.starts_with("textedit:")) { + context_menu::choose(&mut app, &id); + assert_eq!(app.ui.dialog.as_deref(), Some(id.as_str())); + } } + // Several selected texts keep the TEXTEDIT command line: the window edits one object at a time. + let mut several = app(); + several.run("text", json!({ "at": [0, 0], "text": "hi" })).unwrap(); + several.run("text", json!({ "at": [0, 4], "text": "ho" })).unwrap(); + select_all(&mut several); + assert!(ids(&[context_menu::object_entries(&several)]).iter().any(|i| i == "textedit")); // Polyline Edit, not the command's bare "Polyline" label. - let mut app = app(); - app.run("pline", json!({ "vertices": [[0, 0], [10, 0]] })).unwrap(); - select_all(&mut app); - assert_eq!(labels(&[context_menu::object_entries(&app)]), ["Polyline Edit"]); + let mut pline = app(); + pline.run("pline", json!({ "vertices": [[0, 0], [10, 0]] })).unwrap(); + select_all(&mut pline); + assert_eq!(labels(&[context_menu::object_entries(&pline)]), ["Polyline Edit"]); } #[test]