summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppcodecompletion.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2009-09-22 16:52:27 +0200
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2009-09-22 16:54:16 +0200
commitbf74d21d6c39bade8b47e8c4982325b2adb6c6c7 (patch)
tree6a35d46ab222e6746f925a68f404a90522bbb65c /src/plugins/cpptools/cppcodecompletion.cpp
parent7a920e46b22b3b6c6a2aa581cb07debe04903bca (diff)
downloadqt-creator-bf74d21d6c39bade8b47e8c4982325b2adb6c6c7.tar.gz
Avoid completing a closing parenthesis in the wrong place
Need to check the character to the right of the cursor.
Diffstat (limited to 'src/plugins/cpptools/cppcodecompletion.cpp')
-rw-r--r--src/plugins/cpptools/cppcodecompletion.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp
index 4c7c0a038f..63a4d4c6cc 100644
--- a/src/plugins/cpptools/cppcodecompletion.cpp
+++ b/src/plugins/cpptools/cppcodecompletion.cpp
@@ -46,6 +46,7 @@
#include <cplusplus/ResolveExpression.h>
#include <cplusplus/LookupContext.h>
+#include <cplusplus/MatchingText.h>
#include <cplusplus/Overview.h>
#include <cplusplus/ExpressionUnderCursor.h>
#include <cplusplus/TokenUnderCursor.h>
@@ -1510,11 +1511,14 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
if (endWithSemicolon)
extraChars += QLatin1Char(';');
} else if (autoParenthesesEnabled) {
- extraChars += QLatin1Char(')');
- --cursorOffset;
- if (endWithSemicolon) {
- extraChars += QLatin1Char(';');
+ const QChar lookAhead = m_editor->characterAt(m_editor->position() + 1);
+ if (MatchingText::shouldInsertMatchingText(lookAhead)) {
+ extraChars += QLatin1Char(')');
--cursorOffset;
+ if (endWithSemicolon) {
+ extraChars += QLatin1Char(';');
+ --cursorOffset;
+ }
}
}
}