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

View File

@@ -283,8 +283,15 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
// Ctrl+Enter for newline, Enter for submit // Ctrl+Enter for newline, Enter for submit
if (key.return) { if (key.return) {
if (key.ctrl) { const [row, col] = buffer.cursor;
// Ctrl+Enter for newline 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(); buffer.newline();
} else { } else {
// Enter for submit // Enter for submit