Preferences: a restored Hold Shortcut Delay outside its range opens as the delay in use

A settings file can hold a Hold Shortcut Delay outside 0.2 to 1 s. The
dialog showed the value brought into range but kept the saved one, so OK
sent it to prefs.set and failed. The dialog now opens with the delay in
use, and OK keeps it.
This commit is contained in:
dotCooCoo
2026-11-16 11:07:17 -08:00
parent d8529f111d
commit f5afbf0acc
2 changed files with 18 additions and 0 deletions
+5
View File
@@ -32,6 +32,11 @@ pub fn open(app: &mut VectorcraftApp, category: Option<&str>) {
// One field per preference key or group (the flattener presets have commands of their own).
let mut fields: Map<String, Value> = app.session.prefs.to_json().as_object().cloned().unwrap_or_default();
fields.retain(|k, _| vectorcraft_engine::cmd::prefscmds::spec(k).is_some() || PREF_GROUPS.contains(&k.as_str()));
// A restored settings file can hold a Hold Shortcut Delay outside its range: the dialog shows,
// and OK sets, the delay in use.
if fields.contains_key("keyHoldDelay") {
fields.insert("keyHoldDelay".into(), json!(app.session.prefs.key_hold_delay()));
}
// Units ▸ General shows (and OK sets) the open document's units.
if let Some(st) = app.session.active() {
fields.insert("unitsGeneral".into(), json!(st.doc.units.key()));
+13
View File
@@ -1136,6 +1136,19 @@ fn hold_shortcut_delay_dims_without_hold_shortcuts() {
}
}
/// A restored Hold Shortcut Delay outside its range opens as the delay in use, and OK keeps it.
#[test]
fn a_restored_hold_shortcut_delay_outside_its_range_opens_as_the_delay_in_use() {
for (saved, used) in [(5.0, 1.0), (0.05, 0.2)] {
let mut a = app();
a.session.prefs.key_hold_delay = saved;
open(&mut a, Some("General"));
assert_eq!(a.ui.dialog.as_ref().unwrap().fields["keyHoldDelay"], json!(used), "{saved}");
confirm(&mut a).unwrap();
assert_eq!(a.session.prefs.key_hold_delay, used, "{saved}");
}
}
/// Type › Show samples on white: its checkbox is dimmed while Enable in-menu font previews is
/// unchecked in the dialog, and a click on it then leaves the setting as it was.
#[test]