Merge pull request #68 from barrettruth/fix/highlight-unknown-filetypes

fix(parser): emit hunks for files with unknown filetypes
This commit is contained in:
Barrett Ruth 2026-02-04 23:52:13 -05:00 committed by GitHub
commit b4e40e4093
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View file

@ -68,7 +68,7 @@ function M.parse_buffer(bufnr)
local header_lines = {} local header_lines = {}
local function flush_hunk() local function flush_hunk()
if hunk_start and #hunk_lines > 0 and (current_lang or current_ft) then if hunk_start and #hunk_lines > 0 then
local hunk = { local hunk = {
filename = current_filename, filename = current_filename,
ft = current_ft, ft = current_ft,

View file

@ -285,5 +285,24 @@ describe('parser', function()
assert.are.equal('diff --git a/parser.lua b/parser.lua', hunks[1].header_lines[1]) assert.are.equal('diff --git a/parser.lua b/parser.lua', hunks[1].header_lines[1])
delete_buffer(bufnr) delete_buffer(bufnr)
end) end)
it('emits hunk for files with unknown filetype', function()
local bufnr = create_buffer({
'M config.obscuretype',
'@@ -1,2 +1,3 @@',
' setting1 = value1',
'-setting2 = value2',
'+setting2 = MODIFIED',
'+setting4 = newvalue',
})
local hunks = parser.parse_buffer(bufnr)
assert.are.equal(1, #hunks)
assert.are.equal('config.obscuretype', hunks[1].filename)
assert.is_nil(hunks[1].ft)
assert.is_nil(hunks[1].lang)
assert.are.equal(4, #hunks[1].lines)
delete_buffer(bufnr)
end)
end) end)
end) end)