From ec88d279a8d52189685008c8fe46371d13d2505f Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 22 Apr 2024 10:18:09 +0200 Subject: [PATCH] TextEditor: Optimize unindent backspace behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: André Hartmann Reviewed-by: --- src/plugins/texteditor/texteditor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 3256ee91b79..280ca8e433f 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();