Parameters: arrow keys move the cursor while renaming (#1248)
Fixes #1165.
This commit is contained in:
1 parent
2e7f41710b
commit
734f69ad72
2 files changed
+25
-6
No files matched your search
@@ -106,3 +106,21 @@ fn parameter_enter_comment_uses_selected_unit_and_unrelated_focus_does_not_submi
|
||||
assert!(result["parameters"].as_array().unwrap().iter().any(|p| p["name"] == "length" && p["unit"] == "cm" && p["comment"] == "Overall length"));
|
||||
assert_eq!(h.app.session.undo.len(), undo + 1);
|
||||
}
|
||||
#[test]
|
||||
fn parameter_rename_arrow_keys_move_cursor_and_keep_editing() {
|
||||
let mut h = open();
|
||||
h.app.session.execute("parameters.add", &json!({"name":"width","expression":"10 mm"})).unwrap();
|
||||
// Let the click that opened the dialog age, or egui counts the double-click as a triple.
|
||||
h.frames(30);
|
||||
h.run(&json!([{"click":{"handle":"param:name:width"},"double":true}])).unwrap();
|
||||
h.frames(2);
|
||||
let renaming = |h: &Harness| h.app.params.as_ref().unwrap().renaming.clone();
|
||||
assert_eq!(renaming(&h), Some(("width".to_string(), "width".to_string())));
|
||||
// Move the cursor to the start and type there; every arrow key keeps the rename open.
|
||||
h.run(&json!([{"key":"ArrowLeft"}, {"key":"ArrowUp"}, {"key":"ArrowDown"}, {"key":"ArrowRight"}, {"key":"Home"}, {"text":"plate_"}])).unwrap();
|
||||
assert_eq!(renaming(&h), Some(("width".to_string(), "plate_width".to_string())));
|
||||
enter(&mut h, false);
|
||||
assert_eq!(renaming(&h), None);
|
||||
let result = h.app.session.execute("parameters.list", &json!({})).unwrap();
|
||||
assert!(result["parameters"].as_array().unwrap().iter().any(|p| p["name"] == "plate_width"));
|
||||
}
|
||||
Reference in new issue
Block a user