Skip to content

Commit 66e3b58

Browse files
authored
Merge pull request #19636 from Veykril/push-wttkunmqyskm
fix: Fix completion_snippets_custom config always erroring
2 parents 723121e + 5680911 commit 66e3b58

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

crates/rust-analyzer/src/config.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,6 @@ impl Config {
923923
if !(json.is_null() || json.as_object().is_some_and(|it| it.is_empty())) {
924924
let detached_files = get_field_json::<Vec<Utf8PathBuf>>(
925925
&mut json,
926-
// Do not record errors here; it is not an error if a field is missing here.
927926
&mut Vec::new(),
928927
"detachedFiles",
929928
None,
@@ -935,19 +934,20 @@ impl Config {
935934

936935
patch_old_style::patch_json_for_outdated_configs(&mut json);
937936

938-
let snips = get_field_json::<FxIndexMap<String, SnippetDef>>(
939-
&mut json,
940-
// Do not record errors here; it is not an error if a field is missing here.
941-
&mut Vec::new(),
942-
"completion_snippets_custom",
943-
None,
944-
)
945-
.unwrap_or(self.completion_snippets_custom().to_owned());
946-
947937
let mut json_errors = vec![];
938+
939+
let input = FullConfigInput::from_json(json, &mut json_errors);
940+
948941
// IMPORTANT : This holds as long as ` completion_snippets_custom` is declared `client`.
949942
config.snippets.clear();
950943

944+
let snips = input
945+
.global
946+
.completion_snippets_custom
947+
.as_ref()
948+
.unwrap_or(&self.default_config.global.completion_snippets_custom);
949+
#[allow(dead_code)]
950+
let _ = Self::completion_snippets_custom;
951951
for (name, def) in snips.iter() {
952952
if def.prefix.is_empty() && def.postfix.is_empty() {
953953
continue;
@@ -974,8 +974,9 @@ impl Config {
974974
)),
975975
}
976976
}
977+
977978
config.client_config = (
978-
FullConfigInput::from_json(json, &mut json_errors),
979+
input,
979980
ConfigErrors(
980981
json_errors
981982
.into_iter()

0 commit comments

Comments
 (0)