diff --git a/crates/ui-egui/src/prefs_dialog.rs b/crates/ui-egui/src/prefs_dialog.rs index c448754567..3794da2399 100644 --- a/crates/ui-egui/src/prefs_dialog.rs +++ b/crates/ui-egui/src/prefs_dialog.rs @@ -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 = 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())); diff --git a/crates/ui-egui/src/prefs_dialog/tests.rs b/crates/ui-egui/src/prefs_dialog/tests.rs index 973a0111f7..2240ddedd2 100644 --- a/crates/ui-egui/src/prefs_dialog/tests.rs +++ b/crates/ui-egui/src/prefs_dialog/tests.rs @@ -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]