fix(highlight): use file context for header text treesitter parsing#197
Merged
barrettruth merged 3 commits intomainfrom Mar 20, 2026
Merged
fix(highlight): use file context for header text treesitter parsing#197barrettruth merged 3 commits intomainfrom
barrettruth merged 3 commits intomainfrom
Conversation
Problem: the `@@ ... @@ end` header context text was parsed by treesitter in isolation. Without surrounding code, tokens like `end` produce ERROR nodes and get no highlight captures. Solution: prepend `hunk.context_before` lines (already computed by `compute_hunk_context`) to give the treesitter string parser enough scope to recognize keywords, closing delimiters, etc. Only captures on the target row produce extmarks.
43ac94f to
961037d
Compare
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
highlight_textparsed header context text (e.g.,endin@@ ... @@ end) in isolation. Without surrounding code, treesitter produced ERROR nodes for tokens likeend, leaving them unhighlighted.Solution
Prepend
hunk.context_beforelines (already computed bycompute_hunk_context) to the treesitter parse string inhighlight_text. Only captures on the target row produce extmarks. Gated by the existinghighlights.context.enabledconfig.