aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2024-04-22 10:18:09 +0200
committerDavid Schulz <david.schulz@qt.io>2024-04-22 10:07:32 +0000
commitec88d279a8d52189685008c8fe46371d13d2505f (patch)
treed802d540f6438ed56125a8e16ab4ecb30acf9bf7 /src/plugins/texteditor
parent89682a866e95a9b675b61fc7aa345b8b492bd1d8 (diff)
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>
Diffstat (limited to 'src/plugins/texteditor')
-rw-r--r--src/plugins/texteditor/texteditor.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index 3256ee91b7..280ca8e433 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -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();