Commit 79bf4183 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer Committed by con
Browse files

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
parent 2b46f828
......@@ -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(']');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment