Fix possible repeat key infinite recursion (#25926)

Guard against infinite recursion when pressing this sequence after fresh boot: repeat key press -> another key press/release -> repeat key release.
This commit is contained in:
windexlight
2026-03-31 03:12:01 -07:00
committed by GitHub
parent c31ebfeb0a
commit 593cd168c6
3 changed files with 55 additions and 16 deletions
+23
View File
@@ -54,6 +54,7 @@ class RepeatKey : public TestFixture {
bool process_record_user_was_called_;
void SetUp() override {
reset_repeat_key_state();
autoshift_disable();
process_record_user_fun = process_record_user_default;
remember_last_key_user_fun = remember_last_key_user_default;
@@ -784,4 +785,26 @@ TEST_F(RepeatKey, IgnoredKeys) {
testing::Mock::VerifyAndClearExpectations(&driver);
}
// Check that on fresh boot, repeat press, another key, repeat release doesn't hang
TEST_F(RepeatKey, RepeatKeyHeldAfterBoot) {
TestDriver driver;
KeymapKey key_a(0, 1, 0, KC_A);
KeymapKey key_repeat(0, 2, 0, QK_REP);
set_keymap({key_a, key_repeat});
EXPECT_EMPTY_REPORT(driver).Times(AnyNumber());
ExpectString(driver, "a");
// Press and hold repeat key, then press and release 'a' key, then release repeat key
key_repeat.press();
run_one_scan_loop();
key_a.press();
run_one_scan_loop();
key_a.release();
run_one_scan_loop();
key_repeat.release();
run_one_scan_loop();
testing::Mock::VerifyAndClearExpectations(&driver);
}
} // namespace