Re-enable check for automatically inserted block end.

This commit is contained in:
Roberto Raggi
2009-09-17 18:54:12 +02:00
parent da4fcd22ef
commit 9a799da6c9
2 changed files with 12 additions and 4 deletions

View File

@@ -1270,16 +1270,25 @@ bool CPPEditor::isElectricCharacter(const QChar &ch) const
}
#if 1
QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &text) const
QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &textToInsert) const
{
bool checkBlockEnd = m_allowSkippingOfBlockEnd;
m_allowSkippingOfBlockEnd = false;
if (!contextAllowsAutoParentheses(cursor))
return QString();
QChar lookAhead = characterAt(cursor.selectionEnd());
QString text = textToInsert;
const QChar lookAhead = characterAt(cursor.selectionEnd());
QString autoText;
int skippedChars = 0;
if (checkBlockEnd && (lookAhead == QChar::ParagraphSeparator && (! text.isEmpty() && text.at(0) == QLatin1Char('}')))) {
skippedChars = 2;
text = text.mid(1);
}
MatchingText matchingText;
autoText = matchingText.insertMatchingBrace(cursor, text, lookAhead, &skippedChars);