diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-01-11 12:54:50 +0100 |
---|---|---|
committer | con <qtc-committer@nokia.com> | 2010-01-11 16:17:28 +0100 |
commit | 79bf4183056d9ae950d44dc538d7276500268293 (patch) | |
tree | 5d5cd0e48f8bb7cd7571ab5c16f503c65f45a0b7 | |
parent | 2b46f828b4ae2f41c4efc9fde7e8b7c5e271b4de (diff) |
Fixed logic for whether to skip or insert a closing brace
Due to wrongly checking whether findPreviousBlockOpenParenthesis and
findNextBlockOpenParenthesis actually found anything, the wrong range
was counted when a code block start or end was not found.
Reviewed-by: mae
-rw-r--r-- | src/plugins/cppeditor/cppeditor.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 91a9e40be7..754192a465 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -1374,11 +1374,11 @@ QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &textToInsert QString brackets = QLatin1String("[]"); if (parentheses.contains(character) || brackets.contains(character)) { QTextCursor tmp= cursor; - TextEditor::TextBlockUserData::findPreviousBlockOpenParenthesis(&tmp); - int blockStart = tmp.isNull() ? 0 : tmp.position(); + bool foundBlockStart = TextEditor::TextBlockUserData::findPreviousBlockOpenParenthesis(&tmp); + int blockStart = foundBlockStart ? tmp.position() : 0; tmp = cursor; - TextEditor::TextBlockUserData::findNextBlockClosingParenthesis(&tmp); - int blockEnd = tmp.isNull() ? (cursor.document()->characterCount()-1) : tmp.position(); + bool foundBlockEnd = TextEditor::TextBlockUserData::findNextBlockClosingParenthesis(&tmp); + int blockEnd = foundBlockEnd ? tmp.position() : (cursor.document()->characterCount() - 1); QChar openChar = parentheses.contains(character) ? QLatin1Char('(') : QLatin1Char('['); QChar closeChar = parentheses.contains(character) ? QLatin1Char(')') : QLatin1Char(']'); |