Skip to content

Fix alt modifier ignored in ANSI_SEQUENCES_KEYS tuple branch#6379

Open
angelsen wants to merge 1 commit intoTextualize:mainfrom
angelsen:fix/alt-enter
Open

Fix alt modifier ignored in ANSI_SEQUENCES_KEYS tuple branch#6379
angelsen wants to merge 1 commit intoTextualize:mainfrom
angelsen:fix/alt-enter

Conversation

@angelsen
Copy link

Fixes #6378

Summary

The _sequence_to_key_events method's tuple branch (keys like Enter, Space, Backspace, Tab) ignored the alt parameter, silently dropping the alt modifier. The single-character branch handled it correctly — this applies the same pattern to the tuple branch.

  • Apply alt+ prefix in tuple branch when alt=True, matching existing single-character branch pattern
  • Add alt+enter and alt+space test cases to existing test_keys parametrize block

Test plan

  • New tests pass: pytest tests/test_xterm_parser.py -k test_keys (9/9 pass)
  • All existing test_xterm_parser.py tests still pass
  • Manual verification: Alt+Enter produces key='alt+enter' in GNOME Console + tmux
  • Formatted with black

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

The `_sequence_to_key_events` method accepts an `alt` parameter but the
tuple branch (matching keys like Enter, Space, Backspace, Tab, and all
Ctrl+letter keys) never applied it. The single-character fallback branch
handled alt correctly, but keys resolved through the tuple branch lost
their alt modifier entirely.

For example, Alt+Enter sends ESC+CR from the terminal. The parser
correctly detected the ESC prefix and passed alt=True into
_sequence_to_key_events("\r", alt=True), but the tuple branch yielded
Key("enter") without checking alt.

Apply the alt prefix in the tuple branch, matching the pattern already
used in the single-character branch.

Add test cases for alt+enter and alt+space to the existing test_keys
parametrize block.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

alt modifier lost for enter space and other ansi tuple-mapped keys

1 participant