forked from qt-creator/qt-creator
ClangCodeModel: Fix dot-to-arrow completion with extra characters
We failed to overwrite existing characters that match the completion if clangd also changes "." to "->" at the same time. Note that it still doesn't work as expected if the cursor is after the dot and before the extra character. I'm not sure yet how to fix that. Fixes: QTCREATORBUG-27034 Change-Id: I852145fc41f34ab60d9e944783e822bc9505453b Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -3230,7 +3230,8 @@ void ClangdCompletionItem::apply(TextDocumentManipulatorInterface &manipulator,
|
||||
QTextCursor cursor = manipulator.textCursorAt(rangeStart);
|
||||
cursor.movePosition(QTextCursor::EndOfWord);
|
||||
const QString textAfterCursor = manipulator.textAt(currentPos, cursor.position() - currentPos);
|
||||
if (textToBeInserted != textAfterCursor
|
||||
if (currentPos < cursor.position()
|
||||
&& textToBeInserted != textAfterCursor
|
||||
&& textToBeInserted.indexOf(textAfterCursor, currentPos - rangeStart) >= 0) {
|
||||
currentPos = cursor.position();
|
||||
}
|
||||
|
Reference in New Issue
Block a user