Integrate merge-request #444 into branch 'master'

Joel Nordell (1):
      add ':' to electric keys for C++ indenting, and check for electric
         keys anywhere on line, not just at beginning

Request-url: http://gitorious.org/qt-creator/qt-creator/merge_requests/444
Reviewed-by: Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
This commit is contained in:
Thorbjørn Lindeijer
2009-05-25 16:31:56 +02:00
2 changed files with 3 additions and 6 deletions

View File

@@ -843,7 +843,8 @@ bool CPPEditor::isElectricCharacter(const QChar &ch) const
{ {
if (ch == QLatin1Char('{') || if (ch == QLatin1Char('{') ||
ch == QLatin1Char('}') || ch == QLatin1Char('}') ||
ch == QLatin1Char('#')) { ch == QLatin1Char('#') ||
ch == QLatin1Char(':')) {
return true; return true;
} }
return false; return false;

View File

@@ -992,11 +992,7 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
const QString text = e->text(); const QString text = e->text();
cursor.insertText(text); cursor.insertText(text);
const QString leftText = cursor.block().text().left(cursor.position() - 1 - cursor.block().position()); indent(document(), cursor, QChar::Null);
if (leftText.simplified().isEmpty()) {
const QChar typedChar = e->text().at(0);
indent(document(), cursor, typedChar);
}
#if 0 #if 0
TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(document()->documentLayout()); TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(document()->documentLayout());
QTC_ASSERT(documentLayout, return); QTC_ASSERT(documentLayout, return);