-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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 Caps Word capitalization when used with Combos + Auto Shift. #17549
Conversation
Motivated by #17240, this commit adds a unit test of using Caps Word together with Combos. The test checks that combo chord keys and result keys work as they should for several combos, including overlapping combos and combos that chord tap-hold keys. To check thoroughly, each scenario is repeated to press the combo chord keys with a few different orders and timings. Surprisingly, all tests of this kind that I have tried pass (on master and develop as of 2022-06-26). Maybe the underlying problem has already been fixed, or the real problem is a scenario that hasn't been covered with this test?
Not sure if you want to pile on here or add to a separate PR (since probably more tests)... But caps words messes with autoshift, and autoshift messes with caps words, too. This fixes it: |
@drashna thanks a bunch for sharing that commit! I'm happy to include the corresponding change here. A few weeks back, PR #17284 was merged to (supposedly) fix Caps Word + Auto Shift and add a unit test. But I could imagine something else slipping through in addition to the "Caps Word + Combos + Auto Shift" scenario addressed in this PR. Is there a particular situation where Caps Word + Auto Shift still breaks that I could add as a unit test? |
Yeah, that was with #17284 applied already. So a few things did get through still. Though, given the complexity and such, I can't say I'm surprised. For instance:
Note that this is using the keycode to trigger caps word, none of the other options for activating caps word. The changes are based on customer reports from ZSA, and internal staff. The commit above is confirmed to fix the issues with both. And I can confirm the behavior, as well. |
If Caps Word and Auto Shift are both active, then currently a rolled press like "A down, B down, A up, B up" will incorrectly produce "Ab". This is because Auto Shift clears the weak shift mod when the A key is released, which in the case of a roll is *after* Caps Word has set the weak shift mod for B when it was pressed. This commit incorporates zsa@42519ed which fixes it. An additional test `AutoShiftRolledShiftedKeys` is added, which would previously fail but passes with this fix.
Thanks @drashna for that clear example! I incorporated your fix into this PR and added a test |
Awesome! Though, I'm still getting reports of it happening in rare occasions when typing very fast. (with caps words and autoshift enabled:
However, I don't think this is a show stopper here. Mostly, wanted to let you know there is some sort of edge case here (it was much worse before the patch I mentioned. |
Got it, thanks for the heads up about the fast typing. Is it by chance an issue reported on Mac OS particularly? I wonder if the following is related: On my qmk-keymap repo, I've had a couple issues where " |
Primarily, yeah, on MacOS, but also Windows, and appears to be a bit inconsistent when it will happen. But the suggested changes seem to help, but not completely. |
…#17549) Signed-off-by: Dušan <dusan.uveric@mitigate.dev>
…#17549) Signed-off-by: Dušan <dusan.uveric@mitigate.dev>
Caps Word + Combos + Auto Shift don't work together, as noted in PR #17240. This PR fixes it.
Description
When Auto Shift is enabled, Caps Word fails to capitalize combo "chord" keys and "result" keys.
The bug only happens where all three features Caps Word + Combos + Auto Shift are active. Caps Word works as intended on non-combo keys when Auto Shift is enabled or on combo keys when Auto Shift is disabled.
Additionally, unrelated to Combos, this PR incorporates zsa@42519ed, which fixes capitalization with rolled key presses when Caps Word + Auto Shift are both active. For instance, rolled keys "A down, B down, A up, B up" incorrectly produces "Ab" instead of "AB". The cause of this bug is similar, with Auto Shift clearing the weak Shift mod that Caps Word sets.
Example
Suppose a combo is defined such that pressing
KC_A
+KC_B
typesKC_X
. Then,KC_A
types "a
", but Caps Word should capitalize it "A
". Similarly forKC_B
.KC_A
+KC_B
chord while Caps Word is on types "x
" but it should produce capital "X
".Investigation
After some printf-debugging, I found the reason for this is that Combos calls
clear_weak_mods()
withindump_key_buffer()
after passing a chord key or result key event (code link), and this clears the weak Left Shift mod that Caps Word sets to capitalize the typed key.For the above
KC_A
+KC_B
=KC_X
combo example, here is an outline of what happens when the chord keyKC_A
is tapped, with both Caps Word and Auto Shift turned on:KC_A
press event. The event is buffered and not passed to other handlers yet.KC_A
release event. Thedump_key_buffer()
function is called to pass along the tap onKC_A
. The following all occurs withindump_key_buffer()
...dump_key_buffer()
callsaction_tapping_process()
to pass the bufferedKC_A
press event.KC_A
press event. The weak Left Shift mod is set to capitalize it.KC_A
press event. The event is buffered and further handling is skipped.action_tapping_process()
.dump_key_buffer()
callsclear_weak_mods()
, clearing the Left Shift mod that Caps Word had set.dump_key_buffer()
callsaction_tapping_process()
a second time to pass theKC_A
release event.KC_A
release event and types lowercase "a
".A similar sequence happens with a combo result key when the
KC_A
+KC_B
chord is tapped:KC_A
press event. This event is buffered.KC_B
press event. Thedump_key_buffer()
function is called to pass along the combo result keyKC_X
...dump_key_buffer()
callsaction_tapping_process()
, passing a press event onKC_X
.KC_X
press event. The weak Left Shift mod is set to capitalize it.KC_X
press event and buffers it.action_tapping_process()
.dump_key_buffer()
callsclear_weak_mods()
, clearing the Left Shift mod that Caps Word had set.dump_key_buffer()
callsaction_tapping_process()
, passing a release event onKC_X
.KC_X
release event and types lowercase "x
".From these outlines, it becomes clear why the bug happens with all three features Caps Word + Combos + Auto Shift used together and not with Caps Word + Combos or Caps Word + Auto Shift.
Fix
Change:
clear_weak_mods();
To:
Not clearing the weak Left Shift mod in
dump_key_buffer()
fixes the bug. It is still fine to clear the other weak mods. To make this change conservatively, we continue to clear all mods unless Caps Word and Auto Shift are both active.Tests
This PR also includes a new "caps_word_combo" test to check Caps Word + Combos, with and without Auto Shift. These tests would fail currently, but pass with the above fix.
Types of Changes
Checklist