fix(parser): exclude git diff metadata from neogit filename patterns#127
Merged
barrettruth merged 1 commit intomainfrom Feb 16, 2026
Merged
fix(parser): exclude git diff metadata from neogit filename patterns#127barrettruth merged 1 commit intomainfrom
barrettruth merged 1 commit intomainfrom
Conversation
Problem: "new file mode 100644" and "deleted file mode 100644" lines in git diff output matched the neogit "new file" and "deleted" filename patterns, corrupting the current filename and breaking syntax highlighting for subsequent hunks. Solution: add negative guards so "new file mode" and "deleted file mode" lines are skipped before the neogit capture runs. Guard order matters for Lua and/not semantics — the negative check must evaluate first to avoid the and-operator returning true instead of the captured string.
Owner
Author
|
@phanen here's the fix. the logic is low key a bit scuffed and may need to get organized in the future. but i tested it with your examples and it fixed it. let me know - i marked this pr as closing the issue. I keep adding new tests but damn, you keep finding things :/ (well, it is good - just wish I thought of these things ahead of time). Thanks again! |
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
Git diff metadata lines like "new file mode 100644" and "deleted file
mode 100644" matched the neogit "new file" and "deleted" filename
patterns in the parser, corrupting the current filename and breaking
syntax highlighting for subsequent hunks.
Closes #120
Solution
Add negative guards so "new file mode" and "deleted file mode" lines
are skipped before the neogit filename capture runs. The guard must
evaluate before the capture due to Lua's and/or short-circuit semantics
— otherwise the and-operator returns true instead of the captured
string.
Added 16 parser tests covering all neogit filename patterns, all git
diff extended header lines that could collide, and integration scenarios
with mixed neogit status + diff metadata buffers.