Skip to content

Commit

Permalink
fix(core): ldml backspace processing should delete all markers
Browse files Browse the repository at this point in the history
- current code would only delete a single marker and fall through
- should loop consuming all markers until a non-marker char is hit
  • Loading branch information
srl295 committed Apr 18, 2024
1 parent 4f2ef49 commit dc965f4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/src/ldml/ldml_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ ldml_processor::process_key_up(ldml_event_state &ldml_state)
void
ldml_processor::process_backspace(ldml_event_state &ldml_state) const {
if (!!bksp_transforms) {
// process with an empty string voa the bksp transforms
// process with an empty string via the bksp transforms
auto matchedContext = process_output(ldml_state, std::u32string(), bksp_transforms.get());

if (matchedContext > 0) {
Expand All @@ -245,15 +245,16 @@ void ldml_event_state::emit_backspace() {
// attempt to get the last char
// TODO-LDML: emoji backspace
auto end = state->context().rbegin();
if (end != state->context().rend()) {
while (end != state->context().rend()) {
if ((*end).type == KM_CORE_CT_CHAR) {
actions.code_points_to_delete++;
state->context().pop_back();
return;
} else if ((*end).type == KM_CORE_BT_MARKER) {
// nothing in actions
// remove any markers before char
state->context().pop_back();
// falls through - end wasn't a character
end++;
// loop again
}
}
/*
Expand Down

0 comments on commit dc965f4

Please sign in to comment.