summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/components/InputPrompt.test.tsx
diff options
context:
space:
mode:
authorJacob Richman <[email protected]>2025-08-19 13:41:08 -0700
committerGitHub <[email protected]>2025-08-19 20:41:08 +0000
commit2143731f6efdf1aafff38ec249caf01a8bcd163e (patch)
treeb9f3a81148192632f65c0bcc21250da11fe12100 /packages/cli/src/ui/components/InputPrompt.test.tsx
parented1fc4ddb39a25fad2c9dd12a250959c050a6343 (diff)
fix(paste) incorrect handling of \\\n in pastes (#6532)
Diffstat (limited to 'packages/cli/src/ui/components/InputPrompt.test.tsx')
-rw-r--r--packages/cli/src/ui/components/InputPrompt.test.tsx37
1 files changed, 37 insertions, 0 deletions
diff --git a/packages/cli/src/ui/components/InputPrompt.test.tsx b/packages/cli/src/ui/components/InputPrompt.test.tsx
index a4aaf6e9..11a0eb48 100644
--- a/packages/cli/src/ui/components/InputPrompt.test.tsx
+++ b/packages/cli/src/ui/components/InputPrompt.test.tsx
@@ -1211,6 +1211,43 @@ describe('InputPrompt', () => {
});
});
+ describe('multiline paste', () => {
+ it.each([
+ {
+ description: 'with \n newlines',
+ pastedText: 'This \n is \n a \n multiline \n paste.',
+ },
+ {
+ description: 'with extra slashes before \n newlines',
+ pastedText: 'This \\\n is \\\n a \\\n multiline \\\n paste.',
+ },
+ {
+ description: 'with \r\n newlines',
+ pastedText: 'This\r\nis\r\na\r\nmultiline\r\npaste.',
+ },
+ ])('should handle multiline paste $description', async ({ pastedText }) => {
+ const { stdin, unmount } = renderWithProviders(
+ <InputPrompt {...props} />,
+ );
+ await wait();
+
+ // Simulate a bracketed paste event from the terminal
+ stdin.write(`\x1b[200~${pastedText}\x1b[201~`);
+ await wait();
+
+ // Verify that the buffer's handleInput was called once with the full text
+ expect(props.buffer.handleInput).toHaveBeenCalledTimes(1);
+ expect(props.buffer.handleInput).toHaveBeenCalledWith(
+ expect.objectContaining({
+ paste: true,
+ sequence: pastedText,
+ }),
+ );
+
+ unmount();
+ });
+ });
+
describe('enhanced input UX - double ESC clear functionality', () => {
it('should clear buffer on second ESC press', async () => {
const onEscapePromptChange = vi.fn();