Skip to content

Commit 00a2fea

Browse files
committed
Throw error when diff contains invalid hunks instead of silently filtering them
1 parent 47fb311 commit 00a2fea

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

  • apps/editor/src/commands/apply-chat-response-command/utils/edit-formats/diffs

‎apps/editor/src/commands/apply-chat-response-command/utils/edit-formats/diffs/diff-processor.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,17 @@ export const apply_diff = (params: {
303303
}
304304
}
305305

306-
const valid_blocks = search_replace_blocks.filter(
307-
(block) => block.search_block_start_index != -2
306+
const invalid_blocks = search_replace_blocks.filter(
307+
(block) => block.search_block_start_index == -2
308308
)
309+
310+
if (invalid_blocks.length > 0) {
311+
throw new Error(
312+
`Failed to apply ${invalid_blocks.length} hunk(s). Aborting diff application for this file.`
313+
)
314+
}
315+
316+
const valid_blocks = search_replace_blocks
309317
valid_blocks.sort(
310318
(a, b) => b.search_block_start_index - a.search_block_start_index
311319
)

0 commit comments

Comments
 (0)