Skip to content

fix(terminal): Shift+Enter no longer submits after inserting a newline - #520

Open
opticon454 wants to merge 1 commit into
Ark0N:masterfrom
opticon454:fix/shift-enter-keypress
Open

opticon454 wants to merge 1 commit into
Ark0N:masterfrom
opticon454:fix/shift-enter-keypress

Conversation

@opticon454

@opticon454 opticon454 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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 keydown and keypress. The Shift/Ctrl+Enter gate only matched keydown. For keypress, xterm discards events carrying Ctrl or Alt but not Shift-only ones, so Shift+Enter's keypress fell through and sent a bare \r (submit) right after the send-key newline.

Reproduced in real xterm.js under headless Chromium with real keystrokes:

Key Old handler New handler
Shift+Enter \r (submits) nothing (newline comes from send-key)
Ctrl+Enter nothing nothing
Alt+Enter ESC\r ESC\r
Enter \r \r

Fix

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 on keydown alone.
  • test/shift-enter-keypress.browser.test.ts: real xterm + Chromium, registered in the browser suite (npm run test:browser).
  • Full CI gate on this branch: typecheck, lint, format, public assets, catalogue and 8512 tests pass.

Tested by hand in the running app by the author.

🤖 Generated with Claude Code

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>
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.

1 participant