feat(parser): support combined diff format

Problem: `parse_buffer` didn't recognize `diff --combined` /
`diff --cc` headers, couldn't parse `@@@` old-side ranges, and
synthesized empty body lines as single-space regardless of prefix
width.

Solution: Add `diff --combined` and `diff --cc` filename patterns,
parse old-side `-start,count` from `@@@` lines, remove
`is_unified_diff` guard on empty body lines, and use
`string.rep(' ', hunk_prefix_width)` for synthetic context lines.
This commit is contained in:
Barrett Ruth 2026-03-05 01:06:37 -05:00
parent 38e0187998
commit bb87ae279b
2 changed files with 14 additions and 5 deletions

View file

@ -163,10 +163,10 @@ describe('parser', function()
end
end)
it('stops hunk at blank line', function()
it('stops hunk at blank line when remaining counts exhausted', function()
local bufnr = create_buffer({
'M test.lua',
'@@ -1,2 +1,3 @@',
'@@ -1,1 +1,2 @@',
' local x = 1',
'+local y = 2',
'',
@ -529,7 +529,8 @@ describe('parser', function()
assert.are.equal(1, #hunks)
assert.are.equal(1, hunks[1].file_new_start)
assert.are.equal(9, hunks[1].file_new_count)
assert.is_nil(hunks[1].file_old_start)
assert.are.equal(1, hunks[1].file_old_start)
assert.are.equal(3, hunks[1].file_old_count)
delete_buffer(bufnr)
end)