diff options
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 29 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py | 39 |
2 files changed, 46 insertions, 22 deletions
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: |