Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): clear core context on invalidate cache #10230

Merged
merged 10 commits into from
Dec 19, 2023
7 changes: 7 additions & 0 deletions common/test/keyboards/baseline/baseline.kpj
Original file line number Diff line number Diff line change
Expand Up @@ -323,5 +323,12 @@
<FileVersion>1.0</FileVersion>
<FileType>.kmn</FileType>
</File>
<File>
<ID>id_k_049___context_and_invalidate</ID>
<Filename>k_049___context_and_invalidate.kmn</Filename>
<Filepath>k_049___context_and_invalidate.kmn</Filepath>
<FileVersion>1.0</FileVersion>
<FileType>.kmn</FileType>
</File>
</Files>
</KeymanDeveloperProject>
6 changes: 3 additions & 3 deletions common/test/keyboards/baseline/k_000___null_keyboard.kmn
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
store(&NAME) '000 - null keyboard'
c Description: Tests null keyboard
c Description: Tests null keyboard
c keys: [K_A][RALT K_B][SHIFT K_C]
c expected: aC
c context:
c expected: C
c context:
rc-swag marked this conversation as resolved.
Show resolved Hide resolved

store(&version) '6.0'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
store(&NAME) '008 - vkey input (ctrl alt 2)'
c Description: Tests basic vkey input with control and alt (Unicode)
c keys: [LCTRL LALT K_A][LCTRL LALT K_B][LCTRL LALT K_C]
c expected: \u0E01\u0E03
c context:
c expected: \u0E03
c context:

store(&version) '6.0'

begin Unicode > use(Main)

group(Main) using keys

+ [CTRL ALT K_A] > U+0E01
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
store(&NAME) '049 - enter_invalidates_context'
c Description: Tests that core context is cleared when kb processor
c determines its invalid. eg Enter key See #10182.
c keys: [K_A][K_B][K_ENTER][K_C]
c expected: c
c context:

store(&version) '10.0'

begin Unicode > use(Main)

group(Main) using keys

c Test if context was not invalidated by [K_ENTER] context will be 'abd'

'a' 'b' + [K_C] > 'abd'

Binary file not shown.
1 change: 1 addition & 0 deletions core/src/kmx/kmx_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ kmx_processor::internal_process_queued_actions(km_core_state *state) {
}
break;
case QIT_INVALIDATECONTEXT:
state->context().clear();
rc-swag marked this conversation as resolved.
Show resolved Hide resolved
state->actions().push_invalidate_context();
break;
default:
Expand Down
2 changes: 2 additions & 0 deletions core/tests/unit/kmx/kmx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ apply_action(
}
} break;
case KM_CORE_IT_INVALIDATE_CONTEXT:
context.clear();
text_store.clear();
std::cout << "action: context invalidated (markers cleared)" << std::endl;
break;
case KM_CORE_IT_EMIT_KEYSTROKE:
Expand Down
3 changes: 2 additions & 1 deletion core/tests/unit/kmx/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ tests = [
'k_045___deadkey_and_context',
'k_046___deadkey_and_contextex',
'k_047___caps_always_off_initially_on',
'k_048___modifier_keys_keep_context'
'k_048___modifier_keys_keep_context',
'k_049___enter_invalidates_context'
]

node = find_program('node', required: true)
Expand Down