Skip to content

fix(parser): emit hunks for files with unknown filetypes#68

Merged
barrettruth merged 1 commit intomainfrom
fix/highlight-unknown-filetypes
Feb 5, 2026
Merged

fix(parser): emit hunks for files with unknown filetypes#68
barrettruth merged 1 commit intomainfrom
fix/highlight-unknown-filetypes

Conversation

@barrettruth
Copy link
Owner

Files with unrecognized extensions (no filetype detection) were receiving no highlighting at all in fugitive status - not even the basic green/red background colors for added/deleted lines.

The issue was in flush_hunk() which required (current_lang or current_ft) to be truthy before emitting a hunk. This meant unknown filetypes were silently discarded.

highlight_hunk() already handles nil ft/lang gracefully - it skips syntax highlighting but still applies DiffsAdd/DiffsDelete backgrounds. This fix lets those hunks through.

Closes #62

Thanks to @phanen for identifying this issue and drafting the fix.

Previously, hunks were discarded entirely if vim.filetype.match()
returned nil. This meant files with unrecognized extensions got no
highlighting at all - not even the basic green/red backgrounds for
added/deleted lines.

Remove the (current_lang or current_ft) condition from flush_hunk()
so all hunks are collected. highlight_hunk() already handles the
case where ft/lang are nil by skipping syntax highlighting but still
applying background colors.

Co-authored-by: phanen <phanen@qq.com>
@barrettruth barrettruth merged commit b4e40e4 into main Feb 5, 2026
7 checks passed
@barrettruth barrettruth deleted the fix/highlight-unknown-filetypes branch February 5, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant