diff options
| author | Billy Biggs <[email protected]> | 2025-06-17 10:03:05 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-17 10:03:05 -0700 |
| commit | 708ba8902a19772aec3f07eebf5961cbc59f2998 (patch) | |
| tree | 4680b3cb8f3cf32fd94931e5f707942cad0368f7 /packages/cli/src/ui/components/InputPrompt.tsx | |
| parent | e59c872b3dea9dee8206f990a761e3bfee3a1194 (diff) | |
Support escaping carriage returns with \ (#1127)
Diffstat (limited to 'packages/cli/src/ui/components/InputPrompt.tsx')
| -rw-r--r-- | packages/cli/src/ui/components/InputPrompt.tsx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/packages/cli/src/ui/components/InputPrompt.tsx b/packages/cli/src/ui/components/InputPrompt.tsx index d31b7106..4d2f299b 100644 --- a/packages/cli/src/ui/components/InputPrompt.tsx +++ b/packages/cli/src/ui/components/InputPrompt.tsx @@ -283,8 +283,15 @@ export const InputPrompt: React.FC<InputPromptProps> = ({ // Ctrl+Enter for newline, Enter for submit if (key.return) { - if (key.ctrl) { - // Ctrl+Enter for newline + const [row, col] = buffer.cursor; + const line = buffer.lines[row]; + const charBefore = col > 0 ? cpSlice(line, col - 1, col) : ''; + + if (key.ctrl || charBefore === '\\') { + // Ctrl+Enter or escaped newline + if (charBefore === '\\') { + buffer.backspace(); + } buffer.newline(); } else { // Enter for submit |
