Skip to content

Commit 1ef7eb4

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

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ impl Config {
924924
let mut json_errors = vec![];
925925
let detached_files = get_field_json::<Vec<Utf8PathBuf>>(
926926
&mut json,
927-
&mut json_errors,
927+
&mut Vec::new(),
928928
"detachedFiles",
929929
None,
930930
)
@@ -936,17 +936,19 @@ impl Config {
936936
patch_old_style::patch_json_for_outdated_configs(&mut json);
937937

938938
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());
939+
940+
let input = FullConfigInput::from_json(json, &mut json_errors);
946941

947942
// IMPORTANT : This holds as long as ` completion_snippets_custom` is declared `client`.
948943
config.snippets.clear();
949944

945+
let snips = input
946+
.global
947+
.completion_snippets_custom
948+
.as_ref()
949+
.unwrap_or(&self.default_config.global.completion_snippets_custom);
950+
#[allow(dead_code)]
951+
let _ = Self::completion_snippets_custom;
950952
for (name, def) in snips.iter() {
951953
if def.prefix.is_empty() && def.postfix.is_empty() {
952954
continue;
@@ -973,8 +975,9 @@ impl Config {
973975
)),
974976
}
975977
}
978+
976979
config.client_config = (
977-
FullConfigInput::from_json(json, &mut json_errors),
980+
input,
978981
ConfigErrors(
979982
json_errors
980983
.into_iter()

0 commit comments

Comments
 (0)