mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 11:20:54 +00:00
Auto merge of #13980 - Veykril:checkOnSaveConfigPatch, r=Veykril
Fix checkOnSave to check config patching not always working This early return was missed in the initial PR, so if we aren't patching the `completion_addCallArgumentSnippets` `completion_addCallParenthesis` configs we won't be patching the checkOnSave ones...
This commit is contained in:
commit
760f2ff58d
@ -114,16 +114,18 @@ pub(super) fn patch_json_for_outdated_configs(json: &mut Value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// completion_addCallArgumentSnippets completion_addCallParenthesis -> completion_callable_snippets
|
// completion_addCallArgumentSnippets completion_addCallParenthesis -> completion_callable_snippets
|
||||||
let res = match (
|
'completion: {
|
||||||
copy.pointer("/completion/addCallArgumentSnippets"),
|
let res = match (
|
||||||
copy.pointer("/completion/addCallParenthesis"),
|
copy.pointer("/completion/addCallArgumentSnippets"),
|
||||||
) {
|
copy.pointer("/completion/addCallParenthesis"),
|
||||||
(Some(Value::Bool(true)), Some(Value::Bool(true))) => json!("fill_arguments"),
|
) {
|
||||||
(_, Some(Value::Bool(true))) => json!("add_parentheses"),
|
(Some(Value::Bool(true)), Some(Value::Bool(true))) => json!("fill_arguments"),
|
||||||
(Some(Value::Bool(false)), Some(Value::Bool(false))) => json!("none"),
|
(_, Some(Value::Bool(true))) => json!("add_parentheses"),
|
||||||
(_, _) => return,
|
(Some(Value::Bool(false)), Some(Value::Bool(false))) => json!("none"),
|
||||||
};
|
(_, _) => break 'completion,
|
||||||
merge(json, json!({ "completion": { "callable": {"snippets": res }} }));
|
};
|
||||||
|
merge(json, json!({ "completion": { "callable": {"snippets": res }} }));
|
||||||
|
}
|
||||||
|
|
||||||
// We need to do this due to the checkOnSave_enable -> checkOnSave change, as that key now can either be an object or a bool
|
// We need to do this due to the checkOnSave_enable -> checkOnSave change, as that key now can either be an object or a bool
|
||||||
// checkOnSave_* -> check_*
|
// checkOnSave_* -> check_*
|
||||||
@ -146,3 +148,23 @@ fn merge(dst: &mut Value, src: Value) {
|
|||||||
(dst, src) => *dst = src,
|
(dst, src) => *dst = src,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn check_on_save_patching() {
|
||||||
|
let mut json = json!({ "checkOnSave": { "overrideCommand": "foo" }});
|
||||||
|
patch_json_for_outdated_configs(&mut json);
|
||||||
|
assert_eq!(
|
||||||
|
json,
|
||||||
|
json!({ "checkOnSave": { "overrideCommand": "foo" }, "check": { "overrideCommand": "foo" }})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn check_on_save_patching_enable() {
|
||||||
|
let mut json = json!({ "checkOnSave": { "enable": true, "overrideCommand": "foo" }});
|
||||||
|
patch_json_for_outdated_configs(&mut json);
|
||||||
|
assert_eq!(
|
||||||
|
json,
|
||||||
|
json!({ "checkOnSave": true, "check": { "enable": true, "overrideCommand": "foo" }})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user