TEXTEDIT: the context-menu test follows the window entry, several texts keep the command

This commit is contained in:
霁伪
2026-11-02 07:23:09 +08:00
parent df26fc5197
commit 44950708ba
2 changed files with 22 additions and 14 deletions
+1 -7
View File
@@ -160,13 +160,7 @@ fn object_commands(app: &CadApp) -> Vec<(&'static str, Option<&'static str>)> {
pub fn object_entries(app: &CadApp) -> Vec<Entry> {
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()
}
+21 -7
View File
@@ -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]