Omit quotes from completion if triggered with quote
Typing a single or double quote in an external editor triggers
auto-completion. The returned CompletionItem should not include
quotes since they're already in the editor.
CompletionParams was missing context in to_json() and this is
required to detect whether a quote was typed.
(cherry picked from commit 7ea4247c3d
)
This commit is contained in:
parent
2d82ab735c
commit
ced93eb2e5
|
@ -305,6 +305,15 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) {
|
|||
}
|
||||
}
|
||||
|
||||
if (item.kind == lsp::CompletionItemKind::Method) {
|
||||
bool is_trigger_character = params.context.triggerKind == lsp::CompletionTriggerKind::TriggerCharacter;
|
||||
bool is_quote_character = params.context.triggerCharacter == "\"" || params.context.triggerCharacter == "'";
|
||||
|
||||
if (is_trigger_character && is_quote_character && item.insertText.is_quoted()) {
|
||||
item.insertText = item.insertText.unquote();
|
||||
}
|
||||
}
|
||||
|
||||
return item.to_json(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -1460,6 +1460,17 @@ struct CompletionParams : public TextDocumentPositionParams {
|
|||
TextDocumentPositionParams::load(p_params);
|
||||
context.load(p_params["context"]);
|
||||
}
|
||||
|
||||
Dictionary to_json() {
|
||||
Dictionary ctx;
|
||||
ctx["triggerCharacter"] = context.triggerCharacter;
|
||||
ctx["triggerKind"] = context.triggerKind;
|
||||
|
||||
Dictionary dict;
|
||||
dict = TextDocumentPositionParams::to_json();
|
||||
dict["context"] = ctx;
|
||||
return dict;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue