fix(highlight,parser,init): line_hl_group, clear_end, did_filetype, email-quoted diffs

Problem: line backgrounds used `hl_group + end_row` multirow extmarks
vulnerable to adjacent `clear_namespace`. `clear_end` was off by one.
`vim.filetype.match` returned nil for function-handled extensions
(`.sh`, `.bash`, etc.) when `did_filetype() != 0`. Parser didn't
handle email-quoted diff prefixes (`> `).

Solution: use `line_hl_group` single-point extmarks. Fix `clear_end`
to `hunk.start_line + #hunk.lines`. Override `vim.fn.did_filetype`
via `rawset` during retry. Strip `> ` quote prefixes in parser and
store `quote_width` per hunk.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Barrett Ruth 2026-03-04 17:29:19 -05:00
parent 0f0acacf96
commit 5028f9cc0a
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
9 changed files with 552 additions and 52 deletions

View file

@ -391,6 +391,27 @@ describe('parser', function()
vim.fn.delete(repo_root, 'rf')
end)
it('detects filetype for .sh files when did_filetype() is non-zero', function()
rawset(vim.fn, 'did_filetype', function() return 1 end)
parser._test.ft_lang_cache = {}
local bufnr = create_buffer({
'diff --git a/test.sh b/test.sh',
'@@ -1,3 +1,4 @@',
' #!/usr/bin/env bash',
' set -euo pipefail',
'-echo "running tests..."',
'+echo "running tests with coverage..."',
})
local hunks = parser.parse_buffer(bufnr)
assert.are.equal(1, #hunks)
assert.are.equal('test.sh', hunks[1].filename)
assert.are.equal('sh', hunks[1].ft)
delete_buffer(bufnr)
rawset(vim.fn, 'did_filetype', nil)
end)
it('extracts file line numbers from @@ header', function()
local bufnr = create_buffer({
'M lua/test.lua',