diff --git a/crates/project/src/lsp_command.rs b/crates/project/src/lsp_command.rs index 4c006bb864..a3917e4ef1 100644 --- a/crates/project/src/lsp_command.rs +++ b/crates/project/src/lsp_command.rs @@ -1495,6 +1495,33 @@ impl LspCommand for GetCompletions { })? .ok_or_else(|| anyhow!("no such language server"))?; + let item_defaults = response_list + .as_ref() + .and_then(|list| list.item_defaults.as_ref()); + + if let Some(item_defaults) = item_defaults { + let default_data = item_defaults.data.as_ref(); + let default_commit_characters = item_defaults.commit_characters.as_ref(); + let default_insert_text_mode = item_defaults.insert_text_mode.as_ref(); + + if default_data.is_some() + || default_commit_characters.is_some() + || default_insert_text_mode.is_some() + { + for item in completions.iter_mut() { + if let Some(data) = default_data { + item.data = Some(data.clone()) + } + if let Some(characters) = default_commit_characters { + item.commit_characters = Some(characters.clone()) + } + if let Some(text_mode) = default_insert_text_mode { + item.insert_text_mode = Some(*text_mode) + } + } + } + } + let mut completion_edits = Vec::new(); buffer.update(&mut cx, |buffer, _cx| { let snapshot = buffer.snapshot();