[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/calligra/2.6] libs/kotext/commands: Fix wrong style applied on backspace
From:       Pierre Stirnweiss <pstirnweiss () googlemail ! com>
Date:       2013-01-06 9:11:55
Message-ID: 20130106091155.70F41A60C4 () git ! kde ! org
[Download RAW message or body]

Git commit 08b0eb4f8bd1331099718260a1ff99d3c4a4fb29 by Pierre Stirnweiss.
Committed on 06/01/2013 at 09:55.
Pushed by pstirnweiss into branch 'calligra/2.6'.

Fix wrong style applied on backspace

When using backspace, we keep the char format of the deleted char.
This should not apply when deleting across the newline boundary.

BUG: 312584
REVIEW: 108199

M  +4    -1    libs/kotext/commands/DeleteCommand.cpp

http://commits.kde.org/calligra/08b0eb4f8bd1331099718260a1ff99d3c4a4fb29

diff --git a/libs/kotext/commands/DeleteCommand.cpp b/libs/kotext/commands/DeleteCommand.cpp
index 622062a..06c1528 100644
--- a/libs/kotext/commands/DeleteCommand.cpp
+++ b/libs/kotext/commands/DeleteCommand.cpp
@@ -138,6 +138,7 @@ void DeleteCommand::doDelete()
     Q_ASSERT(textEditor);
     QTextCursor *caret = textEditor->cursor();
     QTextCharFormat charFormat = caret->charFormat();
+    bool caretAtBeginOfBlock = (caret->position() == caret->block().position());
 
     if (!textEditor->hasSelection()) {
         if (m_mode == PreviousChar) {
@@ -176,7 +177,9 @@ void DeleteCommand::doDelete()
 
     caret->deleteChar();
 
-    caret->setCharFormat(charFormat);
+    if (m_mode != PreviousChar || !caretAtBeginOfBlock) {
+        caret->setCharFormat(charFormat);
+    }
 }
 
 void DeleteCommand::deleteTextAnchor(KoInlineObject *object)
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic