8000 fix(terminal): Shift+Enter inserts a newline in TUI apps (Claude Code) by AvoChang · Pull Request #111 · amirlehmam/wmux · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/renderer/hooks/useTerminal.ts
3B4A
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,25 @@ export function useTerminal({ surfaceId, shell, cwd, visible = true, focused = t
})();
return false; // Prevent default — we handle paste ourselves
}
// Shift+Enter → newline for TUI apps (Claude Code, etc). xterm sends a
// plain \r for BOTH Enter and Shift+Enter, so the app can't tell them
// apart and treats Shift+Enter as submit. Emit ESC+CR — the same sequence
// Alt/Option+Enter produces and that Claude Code's /terminal-setup wires
// up — so Shift+Enter inserts a newline instead of submitting. Excludes
// Ctrl/Alt/Meta so Ctrl+Shift+Enter (zoom pane) is left untouched.
if (
event.type === 'keydown' &&
event.key === 'Enter' &&
event.shiftKey &&
!event.ctrlKey &&
!event.altKey &&
!event.metaKey
) {
if (ptyIdRef.current) {
window.wmux.pty.write(ptyIdRef.current, '\x1b\r');
}
return false;
}
return true;
});

Expand Down
0