diff --git a/ui-tui/src/components/textInput.tsx b/ui-tui/src/components/textInput.tsx index 263857a002..ff0bb23c9e 100644 --- a/ui-tui/src/components/textInput.tsx +++ b/ui-tui/src/components/textInput.tsx @@ -10,11 +10,12 @@ import { isActionMod, isMac, isMacActionFallback } from '../lib/platform.js' type InkExt = typeof Ink & { stringWidth: (s: string) => number useDeclaredCursor: (a: { line: number; column: number; active: boolean }) => (el: any) => void + useStdout: () => { stdout?: NodeJS.WriteStream } useTerminalFocus: () => boolean } const ink = Ink as unknown as InkExt -const { Box, Text, useStdin, useInput, stringWidth, useDeclaredCursor, useTerminalFocus } = ink +const { Box, Text, useStdin, useInput, useStdout, stringWidth, useDeclaredCursor, useTerminalFocus } = ink const ESC = '\x1b' const INV = `${ESC}[7m` @@ -293,6 +294,7 @@ export function TextInput({ const [sel, setSel] = useState(null) const fwdDel = useFwdDelete(focus) const termFocus = useTerminalFocus() + const { stdout } = useStdout() const curRef = useRef(cur) const selRef = useRef(null) @@ -787,6 +789,7 @@ export function TextInput({ !selected && !mask && !placeholder && + !!stdout?.isTTY && c === v.length && !v.includes('\n') && stringWidth(text) === text.length && @@ -796,6 +799,7 @@ export function TextInput({ c += text.length if (simpleAppend) { + stdout!.write(text) commit(v, c, true, false) return