Skip to content

Commit 5680911

Browse files
committed
fix: Fix completion_snippets_custom config always erroring
1 parent af301a8 commit 5680911

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -921,10 +921,9 @@ impl Config {
921921
tracing::info!("updating config from JSON: {:#}", json);
922922

923923
if !(json.is_null() || json.as_object().is_some_and(|it| it.is_empty())) {
924-
let mut json_errors = vec![];
925924
let detached_files = get_field_json::<Vec<Utf8PathBuf>>(
926925
&mut json,
927-
&mut json_errors,
926+
&mut Vec::new(),
928927
"detachedFiles",
929928
None,
930929
)
@@ -936,17 +935,19 @@ impl Config {
936935
patch_old_style::patch_json_for_outdated_configs(&mut json);
937936

938937
let mut json_errors = vec![];
939-
let snips = get_field_json::<FxIndexMap<String, SnippetDef>>(
940-
&mut json,
941-
&mut json_errors,
942-
"completion_snippets_custom",
943-
None,
944-
)
945-
.unwrap_or(self.completion_snippets_custom().to_owned());
938+
939+
let input = FullConfigInput::from_json(json, &mut json_errors);
946940

947941
// IMPORTANT : This holds as long as ` completion_snippets_custom` is declared `client`.
948942
config.snippets.clear();
949943

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;
950951
for (name, def) in snips.iter() {
951952
if def.prefix.is_empty() && def.postfix.is_empty() {
952953
continue;
@@ -973,8 +974,9 @@ impl Config {
973974
)),
974975
}
975976
}
977+
976978
config.client_config = (
977-
FullConfigInput::from_json(json, &mut json_errors),
979+
input,
978980
ConfigErrors(
979981
json_errors
980982
.into_iter()

0 commit comments

Comments
 (0)