fix(terminal): Shift+Enter no longer submits after inserting a newline - #520
Open
opticon454 wants to merge 1 commit into
Open
opticon454 wants to merge 1 commit into
opticon454 wants to merge 1 commit into
Conversation
xterm runs the custom key handler for keypress too and drops Ctrl/Alt keypresses but not Shift-only ones, so the stray \r submitted the prompt after the newline. Swallow every event type for Shift/Ctrl+Enter and send only on keydown, in the primary pane and Pane B. Adds a static guard and a real xterm + Chromium browser test. Co-Authored-By: Claude Sonnet 5.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.
Problem
Shift+Enter submitted the prompt instead of inserting a newline, while Ctrl+Enter and Alt+Enter worked.
Cause
xterm runs the custom key handler for
keydownandkeypress. The Shift/Ctrl+Enter gate only matchedkeydown. Forkeypress, xterm discards events carrying Ctrl or Alt but not Shift-only ones, so Shift+Enter'skeypressfell through and sent a bare\r(submit) right after thesend-keynewline.Reproduced in real xterm.js under headless Chromium with real keystrokes:
\r(submits)send-key)ESC\rESC\r\r\rFix
Swallow every event type for Shift/Ctrl+Enter and send only on
keydown, in the main pane (terminal-ui.js) and Pane B (terminal-split.js).Tests
test/shift-enter-keypress-swallowed.test.ts: static guard that the gate is not keyed onkeydownalone.test/shift-enter-keypress.browser.test.ts: real xterm + Chromium, registered in the browser suite (npm run test:browser).Tested by hand in the running app by the author.
🤖 Generated with Claude Code