Support escaping carriage returns with \ (#1127)

This commit is contained in:
Billy Biggs 2025-06-17 10:03:05 -07:00 committed by GitHub
parent e59c872b3d
commit 708ba8902a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 2 deletions

View File

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