From ec88d279a8d52189685008c8fe46371d13d2505f Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 22 Apr 2024 10:18:09 +0200 Subject: 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(-) (limited to 'src/plugins/texteditor') 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(); -- cgit v1.2.3 From 592d7f0c942cc5a804dd07613dc2c5822eee4306 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 22 Apr 2024 14:19:18 +0200 Subject: TextEditor: Fix calculating block highlight background color Fixes: QTCREATORBUG-30649 Change-Id: I9a213ecdf4d58ed6531014c99bbdedac8ac9ef00 Reviewed-by: Christian Stenger --- src/plugins/texteditor/texteditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/texteditor') diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 280ca8e433f..1d90c7481f2 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -4381,7 +4381,7 @@ static QColor calcBlendColor(const QColor &baseColor, int level, int count) if (level == count - 1) return color90; - const int blendFactor = level * (256 / (count - 2)); + const int blendFactor = level * (256 / (count - 1)); return blendColors(color80, color90, blendFactor); } -- cgit v1.2.3