diff options
Diffstat (limited to 'src/libs/cplusplus/MatchingText.cpp')
-rw-r--r-- | src/libs/cplusplus/MatchingText.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp index 86a31fc9ec..76a6fe1ca7 100644 --- a/src/libs/cplusplus/MatchingText.cpp +++ b/src/libs/cplusplus/MatchingText.cpp @@ -71,10 +71,31 @@ static bool isCompleteCharLiteral(const BackwardsScanner &tk, int index, int sta return false; } +static bool shouldInsertMatchingText(const QChar &lookAhead) +{ + if (lookAhead.isSpace()) + return true; + else if (lookAhead == QLatin1Char('{')) + return true; + else if (lookAhead == QLatin1Char('}')) + return true; + else if (lookAhead == QLatin1Char(']')) + return true; + else if (lookAhead == QLatin1Char(')')) + return true; + else if (lookAhead == QLatin1Char(';')) + return true; + else if (lookAhead == QLatin1Char(',')) + return true; + + return false; +} + MatchingText::MatchingText() { } -QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QString &textToProcess, int *skippedChars) const +QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QString &textToProcess, + const QChar &la, int *skippedChars) const { *skippedChars = 0; @@ -101,7 +122,7 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri text = textToProcess.mid(*skippedChars); } - if (text.isEmpty()) + if (text.isEmpty() || !shouldInsertMatchingText(la)) return QString(); BackwardsScanner tk(tc, textToProcess.left(*skippedChars), MAX_NUM_LINES); |