mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-20 11:00:40 -07:00
feat: terse transformations of image paths in text buffer (#4924)
Co-authored-by: Jacob Richman <jacob314@gmail.com> Co-authored-by: owenofbrien <86964623+owenofbrien@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,10 @@ import { act } from 'react';
|
||||
import type { InputPromptProps } from './InputPrompt.js';
|
||||
import { InputPrompt } from './InputPrompt.js';
|
||||
import type { TextBuffer } from './shared/text-buffer.js';
|
||||
import {
|
||||
calculateTransformationsForLine,
|
||||
calculateTransformedLine,
|
||||
} from './shared/text-buffer.js';
|
||||
import type { Config } from '@google/gemini-cli-core';
|
||||
import { ApprovalMode } from '@google/gemini-cli-core';
|
||||
import * as path from 'node:path';
|
||||
@@ -158,6 +162,8 @@ describe('InputPrompt', () => {
|
||||
deleteWordLeft: vi.fn(),
|
||||
deleteWordRight: vi.fn(),
|
||||
visualToLogicalMap: [[0, 0]],
|
||||
visualToTransformedMap: [0],
|
||||
transformationsByLine: [],
|
||||
getOffset: vi.fn().mockReturnValue(0),
|
||||
} as unknown as TextBuffer;
|
||||
|
||||
@@ -2740,6 +2746,59 @@ describe('InputPrompt', () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('image path transformation snapshots', () => {
|
||||
const logicalLine = '@/path/to/screenshots/screenshot2x.png';
|
||||
const transformations = calculateTransformationsForLine(logicalLine);
|
||||
|
||||
const applyVisualState = (visualLine: string, cursorCol: number): void => {
|
||||
mockBuffer.text = logicalLine;
|
||||
mockBuffer.lines = [logicalLine];
|
||||
mockBuffer.viewportVisualLines = [visualLine];
|
||||
mockBuffer.allVisualLines = [visualLine];
|
||||
mockBuffer.visualToLogicalMap = [[0, 0]];
|
||||
mockBuffer.visualToTransformedMap = [0];
|
||||
mockBuffer.transformationsByLine = [transformations];
|
||||
mockBuffer.cursor = [0, cursorCol];
|
||||
mockBuffer.visualCursor = [0, 0];
|
||||
};
|
||||
|
||||
it('should snapshot collapsed image path', async () => {
|
||||
const { transformedLine } = calculateTransformedLine(
|
||||
logicalLine,
|
||||
0,
|
||||
[0, transformations[0].logEnd + 5],
|
||||
transformations,
|
||||
);
|
||||
applyVisualState(transformedLine, transformations[0].logEnd + 5);
|
||||
|
||||
const { stdout, unmount } = renderWithProviders(
|
||||
<InputPrompt {...props} />,
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(stdout.lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should snapshot expanded image path when cursor is on it', async () => {
|
||||
const { transformedLine } = calculateTransformedLine(
|
||||
logicalLine,
|
||||
0,
|
||||
[0, transformations[0].logStart + 1],
|
||||
transformations,
|
||||
);
|
||||
applyVisualState(transformedLine, transformations[0].logStart + 1);
|
||||
|
||||
const { stdout, unmount } = renderWithProviders(
|
||||
<InputPrompt {...props} />,
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(stdout.lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
unmount();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function clean(str: string | undefined): string {
|
||||
|
||||
Reference in New Issue
Block a user