fix: show whitespace changes in edit tool diffs (#17213)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
Saksham Goyal
2026-01-22 23:32:37 +05:30
committed by GitHub
parent fe06f9a1ea
commit 6d7423263b
3 changed files with 21 additions and 4 deletions

View File

@@ -162,4 +162,21 @@ describe('getDiffStat', () => {
user_removed_chars: 0,
});
});
it('should correctly report whitespace-only changes', () => {
const fileName = 'test.py';
const oldStr = 'def hello():\n print("world")';
const aiStr = 'def hello():\n print("world")';
const userStr = aiStr;
const diffStat = getDiffStat(fileName, oldStr, aiStr, userStr);
expect(diffStat).toEqual({
model_added_lines: 1,
model_removed_lines: 1,
model_added_chars: 18,
model_removed_chars: 15,
user_added_lines: 0,
user_removed_lines: 0,
user_added_chars: 0,
user_removed_chars: 0,
});
});
});

View File

@@ -9,7 +9,7 @@ import type { DiffStat } from './tools.js';
export const DEFAULT_DIFF_OPTIONS: Diff.PatchOptions = {
context: 3,
ignoreWhitespace: true,
ignoreWhitespace: false,
};
export function getDiffStat(

View File

@@ -136,7 +136,7 @@ describe('modifyWithEditor', () => {
'Proposed',
expect.objectContaining({
context: 3,
ignoreWhitespace: true,
ignoreWhitespace: false,
}),
);
@@ -205,7 +205,7 @@ describe('modifyWithEditor', () => {
'Proposed',
expect.objectContaining({
context: 3,
ignoreWhitespace: true,
ignoreWhitespace: false,
}),
);
@@ -233,7 +233,7 @@ describe('modifyWithEditor', () => {
'Proposed',
expect.objectContaining({
context: 3,
ignoreWhitespace: true,
ignoreWhitespace: false,
}),
);