mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-19 14:17:40 +00:00
fix(core): update ldml test source to handle reset
- correct invalidate logic Fixes: #10955
This commit is contained in:
parent
784a994f12
commit
55483e4ccc
6 changed files with 17 additions and 9 deletions
|
|
@ -52,8 +52,14 @@ km_core_process_event(km_core_state *state,
|
|||
}
|
||||
km_core_status status = state->processor().process_event(state, vk, modifier_state, is_key_down, event_flags);
|
||||
|
||||
if (state_should_clear_context(state, vk, modifier_state, is_key_down, event_flags)) {
|
||||
if (state_should_invalidate_context(state, vk, modifier_state, is_key_down, event_flags)) {
|
||||
state->context().clear();
|
||||
// we are already committed. So we need to un-commit (remove the end of the vector)
|
||||
if (state->actions().back().type == KM_CORE_IT_END) {
|
||||
state->actions().pop_back();
|
||||
}
|
||||
state->actions().push_invalidate_context();
|
||||
state->actions().commit();
|
||||
}
|
||||
|
||||
state->apply_actions_and_merge_app_context();
|
||||
|
|
|
|||
|
|
@ -373,15 +373,17 @@ state_has_action_type(km_core_state *state, uint8_t type) {
|
|||
}
|
||||
|
||||
bool
|
||||
state_should_clear_context(km_core_state *state,
|
||||
state_should_invalidate_context(km_core_state *state,
|
||||
km_core_virtual_key vk,
|
||||
uint16_t modifier_state,
|
||||
uint8_t is_key_down,
|
||||
uint16_t event_flags) {
|
||||
// if emit_keystroke is present, check if a context reset is needed
|
||||
if (state_has_action_type(state, KM_CORE_IT_EMIT_KEYSTROKE)) {
|
||||
if (vk == KM_CORE_VKEY_BKSP && state_has_action_type(state, KM_CORE_IT_BACK)) {
|
||||
return true;
|
||||
if (vk == KM_CORE_VKEY_BKSP) {
|
||||
if (!state_has_action_type(state, KM_CORE_IT_BACK)) {
|
||||
return true;
|
||||
}
|
||||
} else if (vkey_to_contextreset[vk]) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ struct km_core_state : public km::core::state
|
|||
|
||||
/**
|
||||
* Evaluate the state and vkey used.
|
||||
* Determine whether the context should be cleared.
|
||||
* Determine whether the context should be invalidated.
|
||||
* @param state A pointer to the opaque state object.
|
||||
* @param vk A virtual key that was processed.
|
||||
* @param modifier_state The combinations of modifier keys set at the time key `vk` was pressed, bitmask
|
||||
|
|
@ -198,7 +198,7 @@ struct km_core_state : public km::core::state
|
|||
* @return true if this is a state which should clear the context
|
||||
*/
|
||||
bool
|
||||
state_should_clear_context(km_core_state *state,
|
||||
state_should_invalidate_context(km_core_state *state,
|
||||
km_core_virtual_key vk,
|
||||
uint16_t modifier_state,
|
||||
uint8_t is_key_down,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<!-- TODO: this is not yet a valid keyboard file
|
||||
<!--
|
||||
|
||||
Note that the corresponding .kmx is currently
|
||||
hand-crafted and expected to be invalid
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ run_test(const km::core::path &source, const km::core::path &compiled, km::tests
|
|||
test_state, p.vk, p.modifier_state | test_source.caps_lock_state(), key_down,
|
||||
KM_CORE_EVENT_FLAG_DEFAULT)); // TODO-LDML: for now. Should send touch and hardware events.
|
||||
|
||||
if (state_should_clear_context(test_state, p.vk, p.modifier_state | test_source.caps_lock_state(), key_down,
|
||||
if (state_should_invalidate_context(test_state, p.vk, p.modifier_state | test_source.caps_lock_state(), key_down,
|
||||
KM_CORE_EVENT_FLAG_DEFAULT)) {
|
||||
test_context.clear();
|
||||
text_store.clear();
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ LdmlEmbeddedTestSource::load_source( const km::core::path &path ) {
|
|||
// We must at least have a key sequence to run the test
|
||||
std::cerr << "Need at least one key sequence." << std::endl;
|
||||
return __LINE__;
|
||||
} else if(keys.size() != expected.size()) {
|
||||
} else if(!expected_error && (keys.size() != expected.size())) {
|
||||
std::cerr << "Need the same number of " << s_keys << " and " << s_expected << " lines." << std::endl;
|
||||
return __LINE__;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue