[Libreoffice-commits] core.git: editeng/source sw/qa
Justin Luth (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jan 15 15:05:26 UTC 2021
editeng/source/editeng/impedit2.cxx | 29 ++---------
sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py | 39 ++++++++++++++++
2 files changed, 46 insertions(+), 22 deletions(-)
New commits:
commit 79bfb54665b1a8dc2b932318eb6915d300772cff
Author: Justin Luth <justin.luth at collabora.com>
AuthorDate: Thu Dec 24 13:24:30 2020 +0300
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Jan 15 16:04:40 2021 +0100
tdf#137459 editeng: Ctrl+Del must only delete right
If there was nothing else at the end of the paragraph,
Ctrl+Del was acting like Ctrl+Backspace - it turned
around and started deleting the earlier words.
Instead, we need to keep deleting to the right,
starting with the next paragraph.
That's what Ctrl-Backspace does in reverse anyway.
It looks like this was just a copy-paste mistake
already seen at original import and the few times
that people tried to fix up this area, they didn't
notice that apparently? But then again, the code
changes don't look that impressive either...
[if x == 1, set x=1?]
make UITest_writer_tests UITEST_TEST_NAME=\
tdf137459_editeng_ctrl-DEL.tdf137459.test_tdf137459
Change-Id: I0c2268f9f1a2102997b2e84b0b7a6d0e2da43b15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108265
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth at sil.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index d2596ebd9065..8ea35eb3e91f 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2359,34 +2359,19 @@ EditPaM ImpEditEngine::DeleteLeftOrRight( const EditSelection& rSel, sal_uInt8 n
else if ( nDelMode == DeleteMode::RestOfWord )
{
aDelEnd = EndOfWord( aCurPos );
-
if (aDelEnd.GetIndex() == aCurPos.GetIndex())
{
const sal_Int32 nLen(aCurPos.GetNode()->Len());
-
- // #i120020# when 0 == nLen, aDelStart needs to be adapted, not
- // aDelEnd. This would (and did) lead to a wrong order in the
- // ImpConnectParagraphs call later.
- if(nLen)
+ // end of para?
+ if (aDelEnd.GetIndex() == nLen)
{
- // end of para?
- if (aDelEnd.GetIndex() == nLen)
- {
- aDelEnd = WordLeft( aCurPos );
- }
- else // there's still sth to delete on the right
- {
- aDelEnd = EndOfWord( WordRight( aCurPos ) );
- // if there'n no next word...
- if (aDelEnd.GetIndex() == nLen )
- {
- aDelEnd.SetIndex( nLen );
- }
- }
+ ContentNode* pNext = GetNextVisNode( aCurPos.GetNode() );
+ if ( pNext )
+ aDelEnd = EditPaM( pNext, 0 );
}
- else
+ else // there's still something to delete on the right
{
- aDelStart = WordLeft(aCurPos);
+ aDelEnd = EndOfWord( WordRight( aCurPos ) );
}
}
}
diff --git a/sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py b/sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py
new file mode 100644
index 000000000000..1c8c1e54fef0
--- /dev/null
+++ b/sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py
@@ -0,0 +1,39 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from uitest.framework import UITestCase
+import time
+from uitest.uihelper.common import get_state_as_dict, type_text
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class tdf137459(UITestCase):
+
+ def test_tdf137459(self):
+
+ xMainDoc = self.ui_test.create_doc_in_start_center("writer")
+
+ xMainWindow = self.xUITest.getTopFocusWindow()
+
+ xwriter_edit = xMainWindow.getChild("writer_edit")
+ # adding new Comment
+ self.xUITest.executeCommand(".uno:InsertAnnotation")
+ # wait until the comment is available
+ self.ui_test.wait_until_child_is_available(xMainWindow, 'Comment1')
+
+ xComment1 = xMainWindow.getChild("Comment1")
+ sText = "Ctrl+Del should not delete BACKWARDS"
+ xComment1.executeAction("TYPE", mkPropertyValues({"TEXT": sText}))
+ self.assertEqual(get_state_as_dict(xComment1)["Text"], sText )
+
+ xComment1.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+DELETE"}))
+ self.assertEqual(get_state_as_dict(xComment1)["Text"], sText )
+
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
More information about the Libreoffice-commits
mailing list