Skip to content

Commit f0aff23

Browse files
committed
Remove redundant empty line filtering in diff parser and clean up test case whitespace
1 parent fb14c80 commit f0aff23

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

  • apps/editor/src/commands/apply-chat-response-command/utils/clipboard-parser

‎apps/editor/src/commands/apply-chat-response-command/utils/clipboard-parser/parsers/diff-parser/diff-parser.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@ const process_collected_patch_lines = (params: {
2323
is_single_root: boolean
2424
}): DiffItem | null => {
2525
let lines = [...params.patch_lines_array]
26-
2726
lines = lines.filter((l) => l.length > 0)
2827

29-
while (lines.length > 0 && lines[lines.length - 1].trim() == '') {
30-
lines.pop()
31-
}
32-
3328
const joined_patch_text_for_checks = lines.join('\n')
3429
if (joined_patch_text_for_checks.trim() == '') return null
3530

@@ -463,15 +458,18 @@ const extract_all_code_block_patches = (params: {
463458
}
464459
}
465460
}
461+
466462
if (in_xml_block) {
467463
xml_blocks.push({
468464
start: xml_start,
469465
end: lines.length - 1,
470466
type: 'xml_file'
471467
})
472468
}
469+
473470
code_blocks.push(...xml_blocks)
474471
code_blocks.sort((a, b) => a.start - b.start)
472+
475473
const diff_block_patches = new Map<number, DiffItem[]>()
476474

477475
for (let i = 0; i < code_blocks.length; i++) {

‎apps/editor/src/commands/apply-chat-response-command/utils/clipboard-parser/test-cases/diffs/diff-inner-triple-backticks/1-file.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
```
1313

1414
## Usage
15+

0 commit comments

Comments
 (0)