PM: merge H4 string and path settings controls, live assist settings
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
e969f6497c
19 changed files with 1149 additions and 41 deletions
|
|
@ -248,6 +248,33 @@ pub const DEFS: &[Def] = &[
|
|||
description_key: "settings.editor.autosave.idleSeconds.description",
|
||||
section: "editor",
|
||||
},
|
||||
Def {
|
||||
key: "editor.completion.autoPopup",
|
||||
kind: Kind::Bool,
|
||||
default: DefaultValue::Bool(true),
|
||||
label_key: "settings.editor.completion.autoPopup.label",
|
||||
description_key: "settings.editor.completion.autoPopup.description",
|
||||
section: "editor",
|
||||
},
|
||||
Def {
|
||||
key: "editor.completion.delayMs",
|
||||
kind: Kind::Int { min: 0, max: 2000 },
|
||||
default: DefaultValue::Int(0),
|
||||
label_key: "settings.editor.completion.delayMs.label",
|
||||
description_key: "settings.editor.completion.delayMs.description",
|
||||
section: "editor",
|
||||
},
|
||||
Def {
|
||||
key: "editor.hover.delayMs",
|
||||
kind: Kind::Int {
|
||||
min: 100,
|
||||
max: 3000,
|
||||
},
|
||||
default: DefaultValue::Int(350),
|
||||
label_key: "settings.editor.hover.delayMs.label",
|
||||
description_key: "settings.editor.hover.delayMs.description",
|
||||
section: "editor",
|
||||
},
|
||||
];
|
||||
|
||||
/// Looks a known setting up by key.
|
||||
|
|
@ -631,6 +658,40 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn assist_defaults_and_validation() {
|
||||
let mut s = Settings::in_memory();
|
||||
assert_eq!(s.get("editor.completion.autoPopup"), Some(json!(true)));
|
||||
assert_eq!(s.get("editor.completion.delayMs"), Some(json!(0)));
|
||||
assert_eq!(s.get("editor.hover.delayMs"), Some(json!(350)));
|
||||
assert_eq!(s.set("editor.completion.autoPopup", json!(false)), Ok(true));
|
||||
assert!(matches!(
|
||||
s.set("editor.completion.autoPopup", json!("false")),
|
||||
Err(SetError::Invalid(_))
|
||||
));
|
||||
for (key, min, max) in [
|
||||
("editor.completion.delayMs", 0, 2000),
|
||||
("editor.hover.delayMs", 100, 3000),
|
||||
] {
|
||||
assert!(s.set(key, json!(min)).is_ok(), "{key}");
|
||||
assert_eq!(s.get(key), Some(json!(min)));
|
||||
assert_eq!(s.set(key, json!(max)), Ok(true), "{key}");
|
||||
for bad in [json!(min - 1), json!(max + 1), json!(500.5), json!("500")] {
|
||||
assert!(
|
||||
matches!(s.set(key, bad), Err(SetError::Invalid(_))),
|
||||
"{key}"
|
||||
);
|
||||
}
|
||||
let info = serde_json::to_value(def(key).unwrap().info()).unwrap();
|
||||
assert_eq!(info["type"], json!("int"));
|
||||
assert_eq!(
|
||||
(info["min"].clone(), info["max"].clone()),
|
||||
(json!(min), json!(max))
|
||||
);
|
||||
assert_eq!(info["section"], json!("editor"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_default_is_valid() {
|
||||
for d in DEFS {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue