Conversation
…ence Ghostty in xterm modifyOtherKeys mode (enabled by Hermes for Ghostty terminals) encodes Shift+letters as ESC[27;2;<cp>~. install_modify_other_keys_aliases() maps these to single-character string keys, but prompt_toolkit's Vt100Parser._call_handler attaches the raw matched sequence as the KeyPress data, and the self-insert binding inserts event.data — so Shift+F typed literal '[27;2;70~' into the prompt buffer. install_vt100_single_char_data_fix() rewrites data to the mapped character for single-char string keys, fixing Shift+letter, Shift+Space, and dead Alt+letter combos at the source. Normal typing and enum keys (Ctrl+C etc.) are unaffected. Adds regression tests covering Shift+F, Shift+Space, Alt+a, plain letters, Ctrl+C, and idempotency.
Contributor
Author
|
Fair enough. #88097 covers this and then some — no point in two PRs fixing the same thing. Closing mine in favour of theirs. |
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.
Summary
Typing Shift+letters in the Hermes CLI prompt on Ghostty (xterm modifyOtherKeys mode, which Hermes enables for Ghostty terminals via
_is_ghostty_terminal) inserts literal escape text like[27;2;70~instead of the character. Same root cause kills Alt+letter combos (dead keys, empty data) and Shift+Space.Root cause:
install_modify_other_keys_aliases()mapsESC[27;2;<cp>~to single-character string keys ('F',' '), but prompt_toolkit'sVt100Parser._call_handlerattaches the raw matched sequence as theKeyPress.data, and theself-insertbinding insertsevent.data— so the escape text lands in the buffer.Fix: new
install_vt100_single_char_data_fix()(hermes_cli/pt_input_extras.py) rewritesdatato the mapped character for single-char string keys, called from the cli.py startup block. Fixes Shift+letter, Shift+Space, and dead Alt+letter at the source. Normal typing (key == data already) and enum keys (Ctrl+C) are untouched.Test Plan
tests/cli/test_cli_shift_letter_data_fix.py: 6 tests — Shift+F →('F','F'), Shift+Space →(' ',' '), Alt+a → Escape +('a','a'), plainFunchanged, Ctrl+C →Keys.ControlC, idempotency.pytest tests/cli/test_cli_shift_letter_data_fix.py tests/cli/test_cli_shift_enter_newline.py tests/cli/test_cli_cmd_backspace.py→ 22 passed.