forked from qt-creator/qt-creator
Avoid completing a closing parenthesis in the wrong place
Need to check the character to the right of the cursor.
This commit is contained in:
@@ -1862,5 +1862,3 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
|
|||||||
|
|
||||||
return semanticInfo;
|
return semanticInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
#include <cplusplus/ResolveExpression.h>
|
#include <cplusplus/ResolveExpression.h>
|
||||||
#include <cplusplus/LookupContext.h>
|
#include <cplusplus/LookupContext.h>
|
||||||
|
#include <cplusplus/MatchingText.h>
|
||||||
#include <cplusplus/Overview.h>
|
#include <cplusplus/Overview.h>
|
||||||
#include <cplusplus/ExpressionUnderCursor.h>
|
#include <cplusplus/ExpressionUnderCursor.h>
|
||||||
#include <cplusplus/TokenUnderCursor.h>
|
#include <cplusplus/TokenUnderCursor.h>
|
||||||
@@ -1510,6 +1511,8 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
|
|||||||
if (endWithSemicolon)
|
if (endWithSemicolon)
|
||||||
extraChars += QLatin1Char(';');
|
extraChars += QLatin1Char(';');
|
||||||
} else if (autoParenthesesEnabled) {
|
} else if (autoParenthesesEnabled) {
|
||||||
|
const QChar lookAhead = m_editor->characterAt(m_editor->position() + 1);
|
||||||
|
if (MatchingText::shouldInsertMatchingText(lookAhead)) {
|
||||||
extraChars += QLatin1Char(')');
|
extraChars += QLatin1Char(')');
|
||||||
--cursorOffset;
|
--cursorOffset;
|
||||||
if (endWithSemicolon) {
|
if (endWithSemicolon) {
|
||||||
@@ -1521,6 +1524,7 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid inserting characters that are already there
|
// Avoid inserting characters that are already there
|
||||||
for (int i = 0; i < extraChars.length(); ++i) {
|
for (int i = 0; i < extraChars.length(); ++i) {
|
||||||
|
|||||||
Reference in New Issue
Block a user