diff options
author | Kurt Lachmann <lachmannk@gmail.com> | 2022-03-24 20:24:47 +0100 |
---|---|---|
committer | Kurt Lachmann <lachmannk@gmail.com> | 2022-03-24 20:24:47 +0100 |
commit | bbb07ff8cbd182c46f988b192b2d3882ed78cd5c (patch) | |
tree | 5e362465a0ee2a195744e68194076d81da0e09b1 /modules/gdscript/language_server/gdscript_text_document.cpp | |
parent | bab2ad4d3283a9b4e6050a2345a4ea408001484e (diff) | |
download | redot-engine-bbb07ff8cbd182c46f988b192b2d3882ed78cd5c.tar.gz |
Use insertText from the internal autocompletion
* GDScriptLanguage::complete_code already adds parentheses to function calls, and does this a lot smarter than the language server right now.
* Instead of the previous naive approach we now reuse the same logic as the internal editor.
* For this to have any effect we also have to send the `insertText` field already during the completionRequest and not only during resolve.
Diffstat (limited to 'modules/gdscript/language_server/gdscript_text_document.cpp')
-rw-r--r-- | modules/gdscript/language_server/gdscript_text_document.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index 961295b076..344ef4885b 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -177,6 +177,7 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) { lsp::CompletionItem item; item.label = option.display; item.data = request_data; + item.insertText = option.insert_text; switch (option.kind) { case ScriptCodeCompletionOption::KIND_ENUM: @@ -284,12 +285,7 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) { item.documentation = symbol->render(); } - if ((item.kind == lsp::CompletionItemKind::Method || item.kind == lsp::CompletionItemKind::Function) && !item.label.ends_with("):")) { - item.insertText = item.label + "("; - if (symbol && symbol->children.is_empty()) { - item.insertText += ")"; - } - } else if (item.kind == lsp::CompletionItemKind::Event) { + if (item.kind == lsp::CompletionItemKind::Event) { if (params.context.triggerKind == lsp::CompletionTriggerKind::TriggerCharacter && (params.context.triggerCharacter == "(")) { const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\""; item.insertText = item.label.quote(quote_style); |