summaryrefslogtreecommitdiff
path: root/starmath/qa
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@libreoffice.org>2023-09-11 20:32:22 +0300
committerخالد حسني <khaled@libreoffice.org>2023-09-11 21:24:57 +0200
commitd52feb11c7eab0adf82c1fb410adfd3127bf9497 (patch)
tree4e4d3a09e44d2d20dc66178dd40c48d9581f92e2 /starmath/qa
parentbf11a197519f6637b5a4f1f42436c2c9f262ef97 (diff)
starmath: Fix selection of surrogate pairs in inline editing
Don’t split nodes in the middle of surrogate pairs. Change-Id: I3ce8cf19d4c331e2ead73ed375745e8866b3d7a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156827 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@libreoffice.org>
Diffstat (limited to 'starmath/qa')
-rw-r--r--starmath/qa/cppunit/test_cursor.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/starmath/qa/cppunit/test_cursor.cxx b/starmath/qa/cppunit/test_cursor.cxx
index d76b446e6a41..f5be3f5beeaa 100644
--- a/starmath/qa/cppunit/test_cursor.cxx
+++ b/starmath/qa/cppunit/test_cursor.cxx
@@ -39,12 +39,14 @@ public:
void testCopySelectPaste();
void testCutPaste();
void testCutSelectPaste();
+ void testSelectSurrogatePairs();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testCopyPaste);
CPPUNIT_TEST(testCopySelectPaste);
CPPUNIT_TEST(testCutPaste);
CPPUNIT_TEST(testCutSelectPaste);
+ CPPUNIT_TEST(testSelectSurrogatePairs);
CPPUNIT_TEST_SUITE_END();
private:
@@ -172,6 +174,24 @@ void Test::testCutSelectPaste()
#endif
}
+void Test::testSelectSurrogatePairs()
+{
+ auto xTree = SmParser5().Parse(u"\U0001EE4E");
+ xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0);
+
+ SmCursor aCursor(xTree.get(), xDocShRef.get());
+ ScopedVclPtrInstance<VirtualDevice> pOutputDevice;
+
+ // selct the first character, cut, then paste
+ aCursor.Move(pOutputDevice, MoveRight, false);
+ aCursor.Cut();
+ aCursor.Paste();
+
+#ifndef _WIN32 // FIXME: on Windows clipboard does not work in tests for some reason
+ CPPUNIT_ASSERT_EQUAL(OUString(u"\U0001EE4E"), xDocShRef->GetText());
+#endif
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}