Repository navigation
fix: a Command shortcut no longer leave Command held down - #71
Open
bluzername wants to merge 1 commit into
Open
bluzername wants to merge 1 commit into
bluzername wants to merge 1 commit into
Conversation
Fixes part of awlevin#58 (bug 7, "A Command shortcut leaves Command held down"). press(key, command=True) set the Command flag on the key's own events but never send anything for the Command key itself. On macOS 27 the system then keep Command down after the press (CGEventSourceFlagsState read it held until something send a Command key-up). After that, every letter from type_text arrive as Command+key so nothing reach the document, and the next click is a Command-click. It follow go_back (Command-[) and clear_field (Command-A) too. Fix: send Command's own key down before the key and up after it, in a finally so an interrupted press still release it. Test (TDD): added two tests in tests/test_input_abort.py. test_a_command_shortcut_sends_the_command_key_down_before_and_up_after_the_key checks the full down/up sequence around a Command shortcut. test_the_command_key_goes_back_up_even_when_posting_it_is_interrupted checks the Command key still goes back up when posting it get interrupted. Both fail on main (only 2 events post, the key's own, with the flag set but no separate Command key events) and pass with the fix. Renamed the old test_a_key_goes_back_up_when_interrupted_after_key_down to test_a_plain_key_goes_back_up_when_interrupted_after_key_down and dropped command=True from it, since it is testing the plain key path, not this one, and its old assertion (one event pair with the flag set) is not what command=True produce anymore. Verification: uv run ruff check . && uv run ruff format --check . clean, uv run pytest -q: 732 passed, 2 skipped, 1 xfailed (main has 730, net +2 tests here). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes part of #58 (bug 7, "A Command shortcut leaves Command held down").
press(key, command=True)set the Command flag on the key's own events but never send anything for the Command key itself. On macOS 27 the system then keep Command down after the press (CGEventSourceFlagsStateread it held until something send a Command key-up). After that, every letter fromtype_textarrive as Command+key so nothing reach the document, and the next click is a Command-click. It followgo_back(Command-[) andclear_field(Command-A) too.Fix: send Command's own key down before the key and up after it, in a
finallyso an interrupted press still release it.Test (TDD): added two tests in
tests/test_input_abort.py:test_a_command_shortcut_sends_the_command_key_down_before_and_up_after_the_keychecks the full down/up sequence around a Command shortcut.test_the_command_key_goes_back_up_even_when_posting_it_is_interruptedchecks the Command key still goes back up when posting it get interrupted.Both fail on main (only 2 events post, the key's own, with the flag set but no separate Command key events) and pass with the fix. Renamed the old
test_a_key_goes_back_up_when_interrupted_after_key_downtotest_a_plain_key_goes_back_up_when_interrupted_after_key_downand droppedcommand=Truefrom it, since it was really testing the plain key path, and its old assertion (one event pair with the flag set, no separate Command events) is not whatcommand=Trueproduce anymore with this fix.Verification:
uv run ruff check . && uv run ruff format --check .clean,uv run pytest -q: 732 passed, 2 skipped, 1 xfailed (main has 730, net +2 tests here).🤖 Generated with Claude Code