diff --git a/core/src/ldml/ldml_processor.cpp b/core/src/ldml/ldml_processor.cpp
index 166b8002b8..5ec0b900d5 100644
--- a/core/src/ldml/ldml_processor.cpp
+++ b/core/src/ldml/ldml_processor.cpp
@@ -377,6 +377,10 @@ ldml_event_state::emit_difference(const std::u32string &old_ctxt, const std::u32
// So the BBBBB needs to be removed and then CCC added.
auto ctxt_prefix = mismatch(old_ctxt.begin(), old_ctxt.end(), new_ctxt.begin(), new_ctxt.end());
+ if(ctxt_prefix.first == old_ctxt.end() && ctxt_prefix.second == new_ctxt.end()) {
+ return; // No mismatch. We can just exit, there's nothing to do.
+ }
+
// handle a special case where we're simply changing from one marker to another.
// Example:
// 0. old_ctxtstr_changed ends with … U+FFFF U+0008 | U+0001 …
@@ -390,14 +394,14 @@ ldml_event_state::emit_difference(const std::u32string &old_ctxt, const std::u32
// marker change.
// We can detect this because the unchanged_prefix will end with u+FFFF U+0008
//
- // Oh, and yes, test case 'regex-test-8a-0' hits this.
+ // k_212* and k_213* hit this case.
std::u32string common_prefix(old_ctxt.begin(), ctxt_prefix.first);
if (common_prefix.length() >= 2) {
auto iter = common_prefix.rbegin();
if (*(iter++) == LDML_MARKER_CODE && *(iter++) == UC_SENTINEL) {
// adjust the iterator so that the "U+FFFF U+0008" is not a part of the common prefix.
- ctxt_prefix.first -= 2;
- ctxt_prefix.second += 2;
+ ctxt_prefix.first -= 2; // backup the 'mismatch' point to before the FFFF
+ ctxt_prefix.second -= 2; // backup the 'mismatch' point to before the FFFF
// Now, old_ctxtstr_changed and new_ctxtstr_changed will start with U+FFFF U+0008 …
}
}
diff --git a/core/tests/unit/ldml/keyboards/k_212_marker_11057-test.xml b/core/tests/unit/ldml/keyboards/k_212_marker_11057-test.xml
new file mode 100644
index 0000000000..92e2abbf3f
--- /dev/null
+++ b/core/tests/unit/ldml/keyboards/k_212_marker_11057-test.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/tests/unit/ldml/keyboards/k_212_marker_11057.xml b/core/tests/unit/ldml/keyboards/k_212_marker_11057.xml
new file mode 100644
index 0000000000..7bbd2bb94a
--- /dev/null
+++ b/core/tests/unit/ldml/keyboards/k_212_marker_11057.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/tests/unit/ldml/keyboards/k_213_marker_11057.xml b/core/tests/unit/ldml/keyboards/k_213_marker_11057.xml
new file mode 100644
index 0000000000..f137e8d2a4
--- /dev/null
+++ b/core/tests/unit/ldml/keyboards/k_213_marker_11057.xml
@@ -0,0 +1,225 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/tests/unit/ldml/keyboards/meson.build b/core/tests/unit/ldml/keyboards/meson.build
index ca047a67bc..4e0b35803b 100644
--- a/core/tests/unit/ldml/keyboards/meson.build
+++ b/core/tests/unit/ldml/keyboards/meson.build
@@ -28,10 +28,10 @@ tests_without_testdata = [
'k_100_keytest',
'k_101_keytest',
'k_102_keytest',
-
+ 'k_213_marker_11057',
]
-# These tests have a k_001_tiny-test.xml file as well.
+# These tests have a *-test.xml file as well.
tests_with_testdata = [
'ldml_test',
'k_001_tiny',
@@ -44,6 +44,7 @@ tests_with_testdata = [
'k_201_reorder_esk',
'k_210_marker',
'k_211_marker_escape',
+ 'k_212_marker_11057',
]
tests = tests_without_testdata