From 4c07de50b2347bc876c7fe60eb7e82f20d273f4b Mon Sep 17 00:00:00 2001 From: Joel Nordell Date: Mon, 18 May 2009 14:38:22 -0500 Subject: [PATCH] add ':' to electric keys for C++ indenting, and check for electric keys anywhere on line, not just at beginning --- src/plugins/cppeditor/cppeditor.cpp | 3 ++- src/plugins/texteditor/basetexteditor.cpp | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 3d553ea4acc..8659650f988 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -842,7 +842,8 @@ bool CPPEditor::isElectricCharacter(const QChar &ch) const { if (ch == QLatin1Char('{') || ch == QLatin1Char('}') || - ch == QLatin1Char('#')) { + ch == QLatin1Char('#') || + ch == QLatin1Char(':')) { return true; } return false; diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 8af95a69825..5e801ad2675 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -932,11 +932,7 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e) QTextCursor cursor = textCursor(); const QString text = e->text(); cursor.insertText(text); - const QString leftText = cursor.block().text().left(cursor.position() - 1 - cursor.block().position()); - if (leftText.simplified().isEmpty()) { - const QChar typedChar = e->text().at(0); - indent(document(), cursor, typedChar); - } + indent(document(), cursor, QChar::Null); #if 0 TextEditDocumentLayout *documentLayout = qobject_cast(document()->documentLayout()); QTC_ASSERT(documentLayout, return);