forked from 1b-agent/opencadstudio-upstream
fix(input): let a rebound SPACE fire while the command line has focus
A focused text field reports Status::Captured, so the key dispatch dropped SPACE and a CUI rebind of SPACE to FINALIZE never ran while the command line held focus (#1710). Dispatch a captured SPACE as a shortcut only when SPACE is bound to something other than COMMANDSPACE, so the default binding still types a space. The closure stays a plain fn, so a static flag mirrors the binding and is refreshed wherever the bindings change.
This commit is contained in:
1 parent
4b6ced9b8c
commit
cbefecb120
5 files changed
+121
-3
No files matched your search
@@ -1390,6 +1390,7 @@ impl OpenCADStudio {
|
||||
self.shortcut_bindings
|
||||
.entry("SHIFT+TAB".to_string())
|
||||
.or_insert_with(|| "DYNTABPREV".to_string());
|
||||
crate::app::shortcuts::sync_space_dispatch_flag(&self.shortcut_bindings);
|
||||
}
|
||||
|
||||
/// Write the config only when it changed since the last write, so a toggle
|
||||
|
||||
@@ -11499,6 +11499,29 @@ mod free_text_entry_tests {
|
||||
.as_ref()
|
||||
.is_some_and(|cmd| cmd.name() == "PASTECLIP"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn space_bound_to_finalize_finalizes_in_free_text_mode() {
|
||||
// #1710: when the user rebinds SPACE to FINALIZE in the CUI, pressing
|
||||
// SPACE must run FINALIZE even while the command line holds focus,
|
||||
// instead of falling through to the command line's CommandSpace
|
||||
// (space-insert) behavior. FreeText mode distinguishes the two: a
|
||||
// COMMANDSPACE would insert a space, while FINALIZE finishes the edit.
|
||||
let (mut app, _) = app_with_cell_command("");
|
||||
assert_eq!(app.text_entry_mode(), TextEntryMode::FreeText);
|
||||
|
||||
// Bind SPACE to FINALIZE (the CUI assignment from the issue).
|
||||
app.shortcut_bindings
|
||||
.insert("SPACE".to_string(), "FINALIZE".to_string());
|
||||
|
||||
// Pressing SPACE runs FINALIZE, which finishes the edit instead of
|
||||
// inserting a space.
|
||||
let _ = app.update(Message::ShortcutPressed("SPACE".to_string()));
|
||||
assert!(
|
||||
app.tabs[0].active_cmd.is_none(),
|
||||
"SPACE bound to FINALIZE must finalize, not insert a space"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Set or clear one bit of `SELECTIONPREVIEW`.
|
||||
|
||||
Reference in new issue
Block a user