forked from qt-creator/qt-creator
ClangCodeModel: Prevent adding an already-present closing quote
... when doing completion for header includes. Fixes: QTCREATORBUG-31103 Change-Id: Ic2d4eb4abce4f6d0f7d08b0ff0f5e0f54669eb65 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -359,8 +359,14 @@ void ClangdCompletionItem::apply(TextDocumentManipulatorInterface &manipulator,
|
||||
}
|
||||
|
||||
// Avoid inserting characters that are already there
|
||||
// For include file completions, also consider a possibly pre-existing
|
||||
// closing quote or angle bracket.
|
||||
QTextCursor cursor = manipulator.textCursorAt(rangeStart);
|
||||
cursor.movePosition(QTextCursor::EndOfWord);
|
||||
if (kind == CompletionItemKind::File && !textToBeInserted.isEmpty()
|
||||
&& textToBeInserted.right(1) == manipulator.textAt(cursor.position(), 1)) {
|
||||
cursor.setPosition(cursor.position() + 1);
|
||||
}
|
||||
const QString textAfterCursor = manipulator.textAt(currentPos, cursor.position() - currentPos);
|
||||
if (currentPos < cursor.position()
|
||||
&& textToBeInserted != textAfterCursor
|
||||
|
Reference in New Issue
Block a user