Commit 29585b58 authored by oldherl oh's avatar oldherl oh
Browse files

LSP Completion: use textEdit.newText as a workaround

Some LSP server implementation, such as rust-analyzer 2021-11-01,
do not use insertText field, but uses textEdit.

Since we don't have real support for textEdit (see Commit 831a0069),
the field textEdit.newText is used as a workaround here to prevent
a worse fallback to use label as the inserted text.

BUG: 445085
parent c710090c
Pipeline #95235 passed with stage
in 3 minutes and 9 seconds
...@@ -629,6 +629,12 @@ static QList<LSPCompletionItem> parseDocumentCompletion(const QJsonValue &result ...@@ -629,6 +629,12 @@ static QList<LSPCompletionItem> parseDocumentCompletion(const QJsonValue &result
if (insertText.isEmpty()) { if (insertText.isEmpty()) {
insertText = label; insertText = label;
} }
const auto &textEdit = item.value(QStringLiteral("textEdit")).toObject();
if (!textEdit.empty()) {
// Not a proper implementation of textEdit, but a workaround for KDE bug #445085
auto newText = textEdit.value(QStringLiteral("newText")).toString();
insertText = newText;
}
auto kind = static_cast<LSPCompletionItemKind>(item.value(MEMBER_KIND).toInt()); auto kind = static_cast<LSPCompletionItemKind>(item.value(MEMBER_KIND).toInt());
// auto textEdit = parseTextEdit(item.value(QStringLiteral("textEdit")).toObject()); // auto textEdit = parseTextEdit(item.value(QStringLiteral("textEdit")).toObject());
ret.push_back({label, kind, detail, doc, sortText, insertText /*, textEdit*/}); ret.push_back({label, kind, detail, doc, sortText, insertText /*, textEdit*/});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment