mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-28 06:50:35 -07:00
paste transform followup (#17624)
Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
This commit is contained in:
@@ -2987,6 +2987,89 @@ describe('InputPrompt', () => {
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should collapse expanded paste on double-click after the end of the line', async () => {
|
||||
const id = '[Pasted Text: 10 lines]';
|
||||
const largeText =
|
||||
'line1\nline2\nline3\nline4\nline5\nline6\nline7\nline8\nline9\nline10';
|
||||
|
||||
const baseProps = props;
|
||||
const TestWrapper = () => {
|
||||
const [isExpanded, setIsExpanded] = useState(true); // Start expanded
|
||||
const currentLines = isExpanded ? largeText.split('\n') : [id];
|
||||
const currentText = isExpanded ? largeText : id;
|
||||
|
||||
const buffer = {
|
||||
...baseProps.buffer,
|
||||
text: currentText,
|
||||
lines: currentLines,
|
||||
viewportVisualLines: currentLines,
|
||||
allVisualLines: currentLines,
|
||||
pastedContent: { [id]: largeText },
|
||||
transformationsByLine: isExpanded
|
||||
? currentLines.map(() => [])
|
||||
: [
|
||||
[
|
||||
{
|
||||
logStart: 0,
|
||||
logEnd: id.length,
|
||||
logicalText: id,
|
||||
collapsedText: id,
|
||||
type: 'paste',
|
||||
id,
|
||||
},
|
||||
],
|
||||
],
|
||||
visualScrollRow: 0,
|
||||
visualToLogicalMap: currentLines.map(
|
||||
(_, i) => [i, 0] as [number, number],
|
||||
),
|
||||
visualToTransformedMap: currentLines.map(() => 0),
|
||||
getLogicalPositionFromVisual: vi.fn().mockImplementation(
|
||||
(_vRow, _vCol) =>
|
||||
// Simulate that we are past the end of the line by returning something
|
||||
// that getTransformUnderCursor won't match, or having the caller handle it.
|
||||
null,
|
||||
),
|
||||
togglePasteExpansion: vi.fn().mockImplementation(() => {
|
||||
setIsExpanded(!isExpanded);
|
||||
}),
|
||||
getExpandedPasteAtLine: vi
|
||||
.fn()
|
||||
.mockImplementation((row) =>
|
||||
isExpanded && row >= 0 && row < 10 ? id : null,
|
||||
),
|
||||
};
|
||||
|
||||
return <InputPrompt {...baseProps} buffer={buffer as TextBuffer} />;
|
||||
};
|
||||
|
||||
const { stdin, stdout, unmount, simulateClick } = renderWithProviders(
|
||||
<TestWrapper />,
|
||||
{
|
||||
mouseEventsEnabled: true,
|
||||
useAlternateBuffer: true,
|
||||
uiActions,
|
||||
},
|
||||
);
|
||||
|
||||
// Verify initially expanded
|
||||
await waitFor(() => {
|
||||
expect(stdout.lastFrame()).toContain('line1');
|
||||
});
|
||||
|
||||
// Simulate double-click WAY to the right on the first line
|
||||
await simulateClick(stdin, 100, 2);
|
||||
await simulateClick(stdin, 100, 2);
|
||||
|
||||
// Verify it is NOW collapsed
|
||||
await waitFor(() => {
|
||||
expect(stdout.lastFrame()).toContain(id);
|
||||
expect(stdout.lastFrame()).not.toContain('line1');
|
||||
});
|
||||
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should move cursor on mouse click with plain borders', async () => {
|
||||
props.config.getUseBackgroundColor = () => false;
|
||||
props.buffer.text = 'hello world';
|
||||
|
||||
Reference in New Issue
Block a user