diff --git a/core/src/ldml/ldml_processor.cpp b/core/src/ldml/ldml_processor.cpp index 148a32eba3..5554261328 100644 --- a/core/src/ldml/ldml_processor.cpp +++ b/core/src/ldml/ldml_processor.cpp @@ -168,8 +168,22 @@ ldml_processor::process_event( switch (vk) { case KM_KBP_VKEY_BKSP: - state->context().pop_back(); - state->actions().push_backspace(KM_KBP_BT_UNKNOWN); // Assuming we don't know the character + { + KMX_DWORD last_char = 0UL; // Assuming we don't know the character + // attempt to get the last char + auto end = state->context().rbegin(); + if(end != state->context().rend()) { + if((*end).type == KM_KBP_CT_CHAR) { + last_char = (*end).character; + } + } + if (last_char == 0UL) { + state->actions().push_backspace(KM_KBP_BT_UNKNOWN); + } else { + state->actions().push_backspace(KM_KBP_BT_CHAR, last_char); + } + state->context().pop_back(); + } break; default: // Look up the key @@ -179,10 +193,10 @@ ldml_processor::process_event( state->actions().commit(); // finish up and return KM_KBP_STATUS_OK; // Nothing to do- no key } - for(size_t i=0; icontext().push_character(str[i]); - state->actions().push_character(str[i]); + const std::u32string str32 = kmx::u16string_to_u32string(str); + for(size_t i=0; icontext().push_character(str32[i]); + state->actions().push_character(str32[i]); } } state->actions().commit(); diff --git a/core/tests/unit/ldml/keyboards/k_002_tinyu32.xml b/core/tests/unit/ldml/keyboards/k_002_tinyu32.xml new file mode 100644 index 0000000000..1055041696 --- /dev/null +++ b/core/tests/unit/ldml/keyboards/k_002_tinyu32.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/tests/unit/ldml/keyboards/meson.build b/core/tests/unit/ldml/keyboards/meson.build index f833e2a4be..0d3d0af956 100644 --- a/core/tests/unit/ldml/keyboards/meson.build +++ b/core/tests/unit/ldml/keyboards/meson.build @@ -7,7 +7,8 @@ tests = [ # disabling 000 until we have updates to core or to the keyboard so that it passes # 'k_000_null_keyboard', - 'k_001_tiny' + 'k_001_tiny', + 'k_002_tinyu32', ] # Setup kmc