forked from qt-creator/qt-creator
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user