Fix number of lines being reported in rewind confirmation dialog (#18675)

This commit is contained in:
Adib234
2026-02-09 18:11:53 -05:00
committed by GitHub
parent 5d7eabbe7a
commit ec52d7d826
4 changed files with 17 additions and 17 deletions
@@ -41,7 +41,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
debug: vi.fn(),
},
getFileDiffFromResultDisplay: vi.fn(),
computeAddedAndRemovedLines: vi.fn(),
computeModelAddedAndRemovedLines: vi.fn(),
};
});
@@ -68,7 +68,7 @@ describe('rewindFileOps', () => {
});
it('calculates stats for single turn correctly', async () => {
const { getFileDiffFromResultDisplay, computeAddedAndRemovedLines } =
const { getFileDiffFromResultDisplay, computeModelAddedAndRemovedLines } =
await import('@google/gemini-cli-core');
vi.mocked(getFileDiffFromResultDisplay).mockReturnValue({
filePath: 'test.ts',
@@ -88,7 +88,7 @@ describe('rewindFileOps', () => {
},
fileDiff: 'diff',
});
vi.mocked(computeAddedAndRemovedLines).mockReturnValue({
vi.mocked(computeModelAddedAndRemovedLines).mockReturnValue({
addedLines: 3,
removedLines: 3,
});
@@ -124,7 +124,7 @@ describe('rewindFileOps', () => {
describe('calculateRewindImpact', () => {
it('calculates cumulative stats across multiple turns', async () => {
const { getFileDiffFromResultDisplay, computeAddedAndRemovedLines } =
const { getFileDiffFromResultDisplay, computeModelAddedAndRemovedLines } =
await import('@google/gemini-cli-core');
vi.mocked(getFileDiffFromResultDisplay)
.mockReturnValueOnce({
@@ -164,7 +164,7 @@ describe('rewindFileOps', () => {
fileDiff: 'diff2',
});
vi.mocked(computeAddedAndRemovedLines)
vi.mocked(computeModelAddedAndRemovedLines)
.mockReturnValueOnce({ addedLines: 5, removedLines: 3 })
.mockReturnValueOnce({ addedLines: 4, removedLines: 0 });
+3 -3
View File
@@ -14,7 +14,7 @@ import {
coreEvents,
debugLogger,
getFileDiffFromResultDisplay,
computeAddedAndRemovedLines,
computeModelAddedAndRemovedLines,
} from '@google/gemini-cli-core';
export interface FileChangeDetail {
@@ -61,7 +61,7 @@ export function calculateTurnStats(
if (fileDiff) {
hasEdits = true;
const stats = fileDiff.diffStat;
const calculations = computeAddedAndRemovedLines(stats);
const calculations = computeModelAddedAndRemovedLines(stats);
addedLines += calculations.addedLines;
removedLines += calculations.removedLines;
@@ -112,7 +112,7 @@ export function calculateRewindImpact(
if (fileDiff) {
hasEdits = true;
const stats = fileDiff.diffStat;
const calculations = computeAddedAndRemovedLines(stats);
const calculations = computeModelAddedAndRemovedLines(stats);
addedLines += calculations.addedLines;
removedLines += calculations.removedLines;
files.add(fileDiff.fileName);