Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion quantum/process_keycode/process_caps_word.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,17 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
caps_word_reset_idle_timer();
#endif // CAPS_WORD_IDLE_TIMEOUT > 0

// From here on, we only take action on press events.
if (!record->event.pressed) {
#if defined(AUTO_SHIFT_ENABLE)
if (!get_autoshift_state())
#endif
{
del_weak_mods(MOD_BIT(KC_LSFT));
}
return true;
}

// From here on, we only take action on press events.
if (!(mods & ~(MOD_MASK_SHIFT | MOD_BIT(KC_RALT)))) {
switch (keycode) {
// Ignore MO, TO, TG, TT, and OSL layer switch keys.
Expand Down
26 changes: 25 additions & 1 deletion tests/caps_word/test_caps_word.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ TEST_F(CapsWord, IdleTimeout) {
tap_key(key_a);
VERIFY_AND_CLEAR(driver);

EXPECT_EMPTY_REPORT(driver);
EXPECT_NO_REPORT(driver);
idle_for(CAPS_WORD_IDLE_TIMEOUT);
run_one_scan_loop();
VERIFY_AND_CLEAR(driver);
Expand Down Expand Up @@ -205,6 +205,30 @@ TEST_F(CapsWord, ShiftsLettersButNotDigits) {
VERIFY_AND_CLEAR(driver);
}

TEST_F(CapsWord, ClearsWeakShiftOnKeyRelease) {
TestDriver driver;
KeymapKey key_a(0, 0, 0, KC_A);
set_keymap({key_a});

{
InSequence s;
EXPECT_REPORT(driver, (KC_LSFT));
EXPECT_REPORT(driver, (KC_LSFT, KC_A));
EXPECT_EMPTY_REPORT(driver);
}

caps_word_on();
key_a.press();
run_one_scan_loop();
EXPECT_EQ(get_weak_mods(), MOD_BIT(KC_LSFT));

key_a.release();
run_one_scan_loop();
EXPECT_EQ(get_weak_mods(), 0);

VERIFY_AND_CLEAR(driver);
}

// Tests that typing "A, Space, A" produces "Shift+A, Space, A".
TEST_F(CapsWord, SpaceTurnsOffCapsWord) {
TestDriver driver;
Expand Down