diff --git a/src/plugins/clangcodemodel/clangpreprocessorassistproposalitem.cpp b/src/plugins/clangcodemodel/clangpreprocessorassistproposalitem.cpp index 6fb0f2e9990..07fdaba9e54 100644 --- a/src/plugins/clangcodemodel/clangpreprocessorassistproposalitem.cpp +++ b/src/plugins/clangcodemodel/clangpreprocessorassistproposalitem.cpp @@ -58,7 +58,6 @@ void ClangPreprocessorAssistProposalItem::apply(TextEditor::TextDocumentManipula QString extraCharacters; int extraLength = 0; - int cursorOffset = 0; if (isInclude()) { if (!textToBeInserted.endsWith(QLatin1Char('/'))) { @@ -69,11 +68,8 @@ void ClangPreprocessorAssistProposalItem::apply(TextEditor::TextDocumentManipula } } - if (!m_typedCharacter.isNull()) { + if (!m_typedCharacter.isNull()) extraCharacters += m_typedCharacter; - if (cursorOffset != 0) - --cursorOffset; - } // Avoid inserting characters that are already there const int endsPosition = manipulator.positionAt(TextEditor::EndOfLinePosition); @@ -101,9 +97,7 @@ void ClangPreprocessorAssistProposalItem::apply(TextEditor::TextDocumentManipula // Insert the remainder of the name const int length = manipulator.currentPosition() - basePosition + existLength + extraLength; - const bool isReplaced = manipulator.replace(basePosition, length, textToBeInserted); - if (isReplaced && cursorOffset) - manipulator.setCursorPosition(manipulator.currentPosition() + cursorOffset); + manipulator.replace(basePosition, length, textToBeInserted); } void ClangPreprocessorAssistProposalItem::setText(const QString &text)