Merge pull request #96725 from HolonProduction/lsp-omit

LSP: Omit some values based on specification version 3.17
This commit is contained in:
Rémi Verschelde 2024-09-16 13:34:50 +02:00
commit 3b714ded01
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -958,28 +958,30 @@ struct CompletionItem {
/** /**
* A string that should be used when comparing this item * A string that should be used when comparing this item
* with other items. When `falsy` the label is used. * with other items. When omitted the label is used
* as the filter text for this item.
*/ */
String sortText; String sortText;
/** /**
* A string that should be used when filtering a set of * A string that should be used when filtering a set of
* completion items. When `falsy` the label is used. * completion items. When omitted the label is used as the
* filter text for this item.
*/ */
String filterText; String filterText;
/** /**
* A string that should be inserted into a document when selecting * A string that should be inserted into a document when selecting
* this completion. When `falsy` the label is used. * this completion. When omitted the label is used as the insert text
* for this item.
* *
* The `insertText` is subject to interpretation by the client side. * The `insertText` is subject to interpretation by the client side.
* Some tools might not take the string literally. For example * Some tools might not take the string literally. For example
* VS Code when code complete is requested in this example `con<cursor position>` * VS Code when code complete is requested in this example
* and a completion item with an `insertText` of `console` is provided it * `con<cursor position>` and a completion item with an `insertText` of
* will only insert `sole`. Therefore it is recommended to use `textEdit` instead * `console` is provided it will only insert `sole`. Therefore it is
* since it avoids additional client side interpretation. * recommended to use `textEdit` instead since it avoids additional client
* * side interpretation.
* @deprecated Use textEdit instead.
*/ */
String insertText; String insertText;
@ -1034,14 +1036,20 @@ struct CompletionItem {
dict["label"] = label; dict["label"] = label;
dict["kind"] = kind; dict["kind"] = kind;
dict["data"] = data; dict["data"] = data;
dict["insertText"] = insertText; if (!insertText.is_empty()) {
dict["insertText"] = insertText;
}
if (resolved) { if (resolved) {
dict["detail"] = detail; dict["detail"] = detail;
dict["documentation"] = documentation.to_json(); dict["documentation"] = documentation.to_json();
dict["deprecated"] = deprecated; dict["deprecated"] = deprecated;
dict["preselect"] = preselect; dict["preselect"] = preselect;
dict["sortText"] = sortText; if (!sortText.is_empty()) {
dict["filterText"] = filterText; dict["sortText"] = sortText;
}
if (!filterText.is_empty()) {
dict["filterText"] = filterText;
}
if (commitCharacters.size()) { if (commitCharacters.size()) {
dict["commitCharacters"] = commitCharacters; dict["commitCharacters"] = commitCharacters;
} }