From 708ba8902a19772aec3f07eebf5961cbc59f2998 Mon Sep 17 00:00:00 2001
From: Billy Biggs <bbiggs@google.com>
Date: Tue, 17 Jun 2025 10:03:05 -0700
Subject: Support escaping carriage returns with \ (#1127)

---
 packages/cli/src/ui/components/InputPrompt.tsx | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

(limited to 'packages/cli/src/ui/components/InputPrompt.tsx')

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
-- 
cgit v1.2.3

