diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-06-05 10:43:07 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-06-05 12:39:27 +0200 |
commit | 31f46cec1406bb39453f5d909da1321980b0e405 (patch) | |
tree | c1bb7c970112e9205cdd6617a5dced1a504dcda2 /sw/qa | |
parent | ea67891bb9a554efb93f43ae73fc6a9a58dcc040 (diff) |
tdf#144752: UNDO/REDO: make sure to select the replaced content
In the specific case of the bug, the non-empty selection means that
the spell check won't skip the word with the cursor. But this also
establishes consistency with other Undo/Redo cases, which generally
select the text.
Change-Id: Ib7c1c911908dc59947e610d735907be7a363ca87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168423
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter9.cxx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx b/sw/qa/extras/uiwriter/uiwriter9.cxx index a0918742a438..d35abf0b9b2f 100644 --- a/sw/qa/extras/uiwriter/uiwriter9.cxx +++ b/sw/qa/extras/uiwriter/uiwriter9.cxx @@ -648,6 +648,35 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf161172) CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(para, u"NumberingLevel"_ustr)); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf144752) +{ + // Undoing/redoing a replacement must select the new text + createSwDoc(); + SwXTextDocument* pDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pDoc); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + + emulateTyping(*pDoc, u"Some Text"); + CPPUNIT_ASSERT(!pWrtShell->HasSelection()); + // Select "Text", and replace with "Word" + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect*/ true, 4, /*bBasicCall*/ false); + pWrtShell->Replace(u"Word"_ustr, false); + pWrtShell->EndOfSection(); + CPPUNIT_ASSERT(!pWrtShell->HasSelection()); + + // Undo and check, that the "Text" is selected + dispatchCommand(mxComponent, ".uno:Undo", {}); + // Without the fix, this would fail + CPPUNIT_ASSERT(pWrtShell->HasSelection()); + CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, pWrtShell->GetSelText()); + + // Redo and check, that the "Word" is selected + dispatchCommand(mxComponent, ".uno:Redo", {}); + CPPUNIT_ASSERT(pWrtShell->HasSelection()); + CPPUNIT_ASSERT_EQUAL(u"Word"_ustr, pWrtShell->GetSelText()); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); |