forked from qt-creator/qt-creator
LanguageClient: redo completion replacement logic
Instead of trying some magic when applying completion items just replace the text from the current position back to the start of the word. Change-Id: I03ac0f8c9bced88d21bd51f9e5cfa0a3ea25025a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -99,16 +99,11 @@ void LanguageClientCompletionItem::apply(TextDocumentManipulatorInterface &manip
|
|||||||
if (auto edit = m_item.textEdit()) {
|
if (auto edit = m_item.textEdit()) {
|
||||||
applyTextEdit(manipulator, *edit);
|
applyTextEdit(manipulator, *edit);
|
||||||
} else {
|
} else {
|
||||||
const QString textToInsert(m_item.insertText().value_or(text()));
|
QTextCursor cursor = manipulator.textCursorAt(pos);
|
||||||
int length = 0;
|
cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
|
||||||
for (auto it = textToInsert.crbegin(); it != textToInsert.crend(); ++it) {
|
manipulator.replace(cursor.position(),
|
||||||
auto ch = *it;
|
cursor.selectionEnd() - cursor.selectionStart(),
|
||||||
if (ch == manipulator.characterAt(pos - length - 1))
|
m_item.insertText().value_or(m_item.label()));
|
||||||
++length;
|
|
||||||
else if (length != 0)
|
|
||||||
length = 0;
|
|
||||||
}
|
|
||||||
manipulator.replace(pos - length, length, textToInsert);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto additionalEdits = m_item.additionalTextEdits()) {
|
if (auto additionalEdits = m_item.additionalTextEdits()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user