mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-22 11:04:42 -07:00
Support paste markers split across writes. (#11977)
This commit is contained in:
committed by
GitHub
parent
81006605c8
commit
145e099ca5
@@ -46,7 +46,7 @@ class MockStdin extends EventEmitter {
|
||||
pause = vi.fn();
|
||||
|
||||
write(text: string) {
|
||||
this.emit('data', Buffer.from(text));
|
||||
this.emit('data', text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,6 +381,61 @@ describe('KeypressContext - Kitty Protocol', () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
it('should paste start code split over multiple writes', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const pastedText = 'pasted content';
|
||||
|
||||
const { result } = renderHook(() => useKeypressContext(), { wrapper });
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
act(() => {
|
||||
// Split PASTE_START into two parts
|
||||
stdin.write(PASTE_START.slice(0, 3));
|
||||
stdin.write(PASTE_START.slice(3));
|
||||
stdin.write(pastedText);
|
||||
stdin.write(PASTE_END);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(keyHandler).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
expect(keyHandler).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
paste: true,
|
||||
sequence: pastedText,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should paste end code split over multiple writes', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const pastedText = 'pasted content';
|
||||
|
||||
const { result } = renderHook(() => useKeypressContext(), { wrapper });
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
act(() => {
|
||||
stdin.write(PASTE_START);
|
||||
stdin.write(pastedText);
|
||||
// Split PASTE_END into two parts
|
||||
stdin.write(PASTE_END.slice(0, 3));
|
||||
stdin.write(PASTE_END.slice(3));
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(keyHandler).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
expect(keyHandler).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
paste: true,
|
||||
sequence: pastedText,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('debug keystroke logging', () => {
|
||||
|
||||
Reference in New Issue
Block a user