Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Update insert_text_format based on resolved completion (#13041)
Piotr Osiewiczdcb8dc16ca7d
diff --git a/crates/project/src/project.rs b/crates/project/src/project.rsindex 1175fa19921..35f01f13259 100644--- a/crates/project/src/project.rs+++ b/crates/project/src/project.rs@@ -59,9 +59,9 @@ use language::{use log::error;use lsp::{CompletionContext, DiagnosticSeverity, DiagnosticTag, DidChangeWatchedFilesRegistrationOptions,- DocumentHighlightKind, Edit, FileSystemWatcher, LanguageServer, LanguageServerBinary,- LanguageServerId, LspRequestFuture, MessageActionItem, OneOf, ServerCapabilities,- ServerHealthStatus, ServerStatus, TextEdit, Uri,+ DocumentHighlightKind, Edit, FileSystemWatcher, InsertTextFormat, LanguageServer,+ LanguageServerBinary, LanguageServerId, LspRequestFuture, MessageActionItem, OneOf,+ ServerCapabilities, ServerHealthStatus, ServerStatus, TextEdit, Uri,};use lsp_command::*;use node_runtime::NodeRuntime;@@ -6134,6 +6134,14 @@ impl Project {completion.old_range = old_range;}}+ if completion_item.insert_text_format == Some(InsertTextFormat::SNIPPET) {+ // vtsls might change the type of completion after resolution.+ let mut completions = completions.write();+ let completion = &mut completions[completion_index];+ if completion_item.insert_text_format != completion.lsp_completion.insert_text_format {+ completion.lsp_completion.insert_text_format = completion_item.insert_text_format;+ }+ }}#[allow(clippy::too_many_arguments)]