Skip to content

Commit bbd28f7

Browse files
committed
Normalize content by trimming whitespace and handling line endings before calculating diff statistics
1 parent 855eea0 commit bbd28f7

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

  • packages/vscode/src/commands/apply-chat-response-command/utils

‎packages/vscode/src/commands/apply-chat-response-command/utils/review.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,23 @@ const get_diff_stats = (params: {
5858
original_content: string
5959
new_content: string
6060
}): { lines_added: number; lines_removed: number } => {
61-
if (params.original_content == params.new_content) {
61+
const original_content_processed = params.original_content
62+
.split(/\r?\n/)
63+
.map((line) => line.trim())
64+
.join('\n')
65+
const new_content_processed = params.new_content
66+
.split(/\r?\n/)
67+
.map((line) => line.trim())
68+
.join('\n')
69+
if (original_content_processed === new_content_processed) {
6270
return { lines_added: 0, lines_removed: 0 }
6371
}
6472

6573
const patch = createTwoFilesPatch(
6674
'original',
6775
'modified',
68-
params.original_content,
69-
params.new_content,
76+
original_content_processed,
77+
new_content_processed,
7078
undefined,
7179
undefined,
7280
{ context: 0 }

0 commit comments

Comments
 (0)