Open mmccoyd opened 2 years ago
Apparently CAPSWORD changes - into on base layer. Which is fine, but not in the docs. But the inconsistency between OSL tap vs hold remains. Unless it is an optimization to get - more easily.
Or, as precondition said more exactly:
CAPS_WORD down
CAPS_WORD up
OSL down
OSL up
KC_MINS down
KC_MINS up
produces -
CAPS_WORD down
CAPS_WORD up
OSL down
KC_MINS down
KC_MINS up
OSL up
produces _ underscore
diff --git a/tests/caps_word/test_caps_word.cpp b/tests/caps_word/test_caps_word.cpp
index 3f59ed3744..ef689c6458 100644
--- a/tests/caps_word/test_caps_word.cpp
+++ b/tests/caps_word/test_caps_word.cpp
@@ -233,6 +233,58 @@ TEST_F(CapsWord, SpaceTurnsOffCapsWord) {
testing::Mock::VerifyAndClearExpectations(&driver);
}
+// Tests that holding a OSL keeps caps word active and shifts keys on the layer that need to be shifted.
+TEST_F(CapsWord, IgnoresOSLHold) {
+ TestDriver driver;
+ KeymapKey key_a(0, 0, 0, KC_A);
+ KeymapKey key_osl(0, 1, 0, OSL(1));
+ KeymapKey key_b(1, 0, 0, KC_B);
+ set_keymap({key_a, key_osl, key_b});
+
+ // Allow any number of reports with no keys or only modifiers.
+ // clang-format off
+ EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
+ KeyboardReport(),
+ KeyboardReport(KC_LSFT))))
+ .Times(AnyNumber());
+
+ EXPECT_REPORT(driver, (KC_LSFT, KC_B));
+ caps_word_on();
+
+ key_osl.press();
+ run_one_scan_loop();
+ tap_key(key_b);
+ key_osl.release();
+ run_one_scan_loop();
+
+ testing::Mock::VerifyAndClearExpectations(&driver);
+}
+
+// Tests that tapping a OSL keeps caps word active and shifts keys on the layer that need to be shifted.
+TEST_F(CapsWord, IgnoresOSLTap) {
+ TestDriver driver;
+ KeymapKey key_a(0, 0, 0, KC_A);
+ KeymapKey key_osl(0, 1, 0, OSL(1));
+ KeymapKey key_b(1, 0, 0, KC_B);
+ set_keymap({key_a, key_osl, key_b});
+
+ // Allow any number of reports with no keys or only modifiers.
+ // clang-format off
+ EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
+ KeyboardReport(),
+ KeyboardReport(KC_LSFT))))
+ .Times(AnyNumber());
+
+ EXPECT_REPORT(driver, (KC_LSFT, KC_B));
+ caps_word_on();
+
+ tap_key(key_osl);
+ tap_key(key_b);
+ run_one_scan_loop();
+
+ testing::Mock::VerifyAndClearExpectations(&driver);
+}
+
For convenience to a future developer who wants to fix the issue, I quickly wrote a unit-test to check for this bug. IgnoresOSLHold
passes but IgnoresOSLTap
fails, as described in this issue.
Is this still happening on the 0.19.x version. There are some changes that may... help with this.
At least, the unit tests I wrote now pass.
Describe the Bug
With CAPS_WORD off:
With CAPS_WORD on:
To reproduce:
Keymap with -_ on a OSL.
Activate CAPS_WORD
Results:
Tested on
Master and dev with Hillside 52 default_dot_c keymap, a vanilla keymap, with MO(_SYM) changed to OSL(_SYM)
https://github.com/qmk/qmk_firmware/blob/master/keyboards/handwired/hillside/52/keymaps/default_dot_c/keymap.c
System Information
Keyboard: Hillside 52 Revision (if applicable): Operating system: OS X
qmk doctor
output:Git diff
Any keyboard related software installed?
Additional Context