diff options
Diffstat (limited to 'packages/cli/src/ui/components/shared/text-buffer.ts')
| -rw-r--r-- | packages/cli/src/ui/components/shared/text-buffer.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/cli/src/ui/components/shared/text-buffer.ts b/packages/cli/src/ui/components/shared/text-buffer.ts index 5f25f9e0..b13a57c6 100644 --- a/packages/cli/src/ui/components/shared/text-buffer.ts +++ b/packages/cli/src/ui/components/shared/text-buffer.ts @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import stripAnsi from 'strip-ansi'; import { spawnSync } from 'child_process'; import fs from 'fs'; import os from 'os'; @@ -1127,7 +1128,12 @@ export function useTextBuffer({ ) backspace(); else if (key['delete']) del(); - else if (input && !key['ctrl'] && !key['meta']) insert(input); + else if (input && !key['ctrl'] && !key['meta']) { + // Heuristic for paste: if input is longer than 1 char (potential paste) + // strip ANSI escape codes. + const cleanedInput = input.length > 1 ? stripAnsi(input) : input; + insert(cleanedInput); + } const textChanged = text !== beforeText; // After operations, visualCursor might not be immediately updated if the change |
