From 4b93be3228f860c7b96854cfa963fc94b380f458 Mon Sep 17 00:00:00 2001 From: Ty Smith Date: Tue, 26 May 2026 17:00:27 -0700 Subject: [PATCH] docs(macos): clarify repeat-task cleanup releases the key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address @feschber review feedback on PR #441. The repeat-task cleanup already releases the key with the correct CGKeyCode via the existing key_event call at the end of the closure — this commit just expands the surrounding comment to make that explicit and to document why update_modifiers is intentionally NOT called from this path (Mac CGKeyCode vs Linux evdev scancode collision). No behavioral change. Co-Authored-By: Claude Opus 4.7 (1M context) --- input-emulation/src/macos.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/input-emulation/src/macos.rs b/input-emulation/src/macos.rs index b1f6688..282bf5e 100644 --- a/input-emulation/src/macos.rs +++ b/input-emulation/src/macos.rs @@ -106,14 +106,19 @@ impl MacOSEmulation { } } } - // release key when cancelled. + // Always release the key with the correct CGKeyCode, regardless of + // whether the repeat loop ran. This matches @feschber's review + // request: "still release the key repeat task but with the correct + // code." + // // Do NOT call update_modifiers here: `key` is a Mac CGKeyCode but // update_modifiers expects a Linux evdev scancode, and the two // codespaces collide (e.g. Mac LeftShift=56 == Linux KeyLeftAlt=56, // Mac Down=125 == Linux KeyLeftMeta=125), corrupting modifier // state for chords like Shift+Option+X or Cmd+Down. Modifier state - // is owned by the main consume() loop, which calls update_modifiers - // with the correct Linux scancode on the real release event. + // is owned by the main consume() loop, which already calls + // update_modifiers with the correct Linux scancode on the real key + // release event from the client. key_event(event_source.clone(), key, 0, modifiers.get()); }); self.repeat_task = Some(repeat_task);