Avoid triggering indent for electric characters in comments and strings

In comments and strings, electric characters have no syntactical
significance and the unnecessary automatic reindent can be annoying.

Reviewed-by: Erik Verbruggen
This commit is contained in:
Thorbjørn Lindeijer
2010-06-15 12:07:15 +02:00
parent a6e5298591
commit 83dba068ce
6 changed files with 100 additions and 43 deletions

View File

@@ -1332,7 +1332,7 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
cursor.insertText(autoText);
cursor.setPosition(pos);
}
if (!electricChar.isNull())
if (!electricChar.isNull() && contextAllowsElectricCharacters(cursor))
indent(document(), cursor, electricChar);
if (doEditBlock)
@@ -3856,6 +3856,11 @@ bool BaseTextEditor::contextAllowsAutoParentheses(const QTextCursor &cursor,
return false;
}
bool BaseTextEditor::contextAllowsElectricCharacters(const QTextCursor &cursor) const
{
return contextAllowsAutoParentheses(cursor);
}
bool BaseTextEditor::isInComment(const QTextCursor &cursor) const
{
Q_UNUSED(cursor);