diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 1175fa1992..35f01f1325 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)]