TextEditor: Optimize unindent backspace behavior

Only remove more than one character when the cursor is inside the
indentation in the beginning of the line. In all other cases always only
remove one character.

Fixes: QTCREATORBUG-30725
Change-Id: I973101a95768cdd8b1a318972f53423eb72eb157
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
David Schulz
2024-04-22 10:18:09 +02:00
parent 89682a866e
commit ec88d279a8

View File

@@ -6876,8 +6876,7 @@ void TextEditorWidgetPrivate::handleBackspaceKey()
}
}
} else if (typingSettings.m_smartBackspaceBehavior == TypingSettings::BackspaceUnindents) {
const QChar previousChar = q->document()->characterAt(pos - 1);
if (!(previousChar == QLatin1Char(' ') || previousChar == QLatin1Char('\t'))) {
if (c.positionInBlock() > TabSettings::firstNonSpace(c.block().text())) {
if (cursorWithinSnippet)
c.beginEditBlock();
c.deletePreviousChar();