diff options
| author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2024-01-26 13:41:12 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-26 13:41:12 +0000 |
| commit | 9a5b4b0395c5a271a2897afc1a9a167e195c3bd8 (patch) | |
| tree | 4c7c4e5b03bfea4f317d9f7732cb64c44440b23e /cli/lsp | |
| parent | 9951506506ded805ff5eb09b52fb0235c0c3df79 (diff) | |
feat(lsp): complete parameters as tab stops and placeholders (#22126)
Diffstat (limited to 'cli/lsp')
| -rw-r--r-- | cli/lsp/tsc.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index de7c16588..eeb07e003 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -3057,7 +3057,11 @@ fn get_parameters_from_parts(parts: &[SymbolDisplayPart]) -> Vec<String> { matches!(parts.get(idx + 1), Some(next) if next.text == "?"); // Skip `this` and optional parameters. if !is_optional && part.text != "this" { - parameters.push(part.text.clone()); + parameters.push(format!( + "${{{}:{}}}", + parameters.len() + 1, + &part.text + )); } } } else if part.kind == "punctuation" { @@ -3165,7 +3169,9 @@ impl CompletionEntryDetails { specifier, language_server, )?; + let mut insert_text_format = original_item.insert_text_format; let insert_text = if data.use_code_snippet { + insert_text_format = Some(lsp::InsertTextFormat::SNIPPET); Some(format!( "{}({})", original_item @@ -3186,6 +3192,7 @@ impl CompletionEntryDetails { text_edit, additional_text_edits, insert_text, + insert_text_format, // NOTE(bartlomieju): it's not entirely clear to me why we need to do that, // but when `completionItem/resolve` is called, we get a list of commit chars // even though we might have returned an empty list in `completion` request. |
