mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 13:06:00 +03:00
[GH-ISSUE #587] feat: Show parent function/class context in diff hunk headers #159
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#159
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @remorses on GitHub (Jan 25, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/587
Similar to GitHub's diff view, it would be helpful to see which function/method/class a diff hunk belongs to. This provides immediate context about where changes are happening.
Example
Current:
With parent context:
The
@@lines would be styled like dimmed context lines, showing the enclosing scope for each hunk.Implementation idea
Use tree-sitter to query for scope-defining nodes (functions, methods, classes) and find the enclosing scope for each hunk's starting line.
@kommander commented on GitHub (Jan 26, 2026):
Treesitter currently has
metadatafor the highlights, maybe it could be returned with that? I would try to avoid parsing twice. But styling happens lazily in the CodeRenderable. Tricky.One approach could be to optionally use a persistent treesitter parser (already kind of exists in the treesitter worker) and fetch info from that through the CodeRenderable, then it doesn't have to create another parser and parse again. Overhead is memory then though as it will keep the code + the tree in memory all the time. And it gets complex.
@remorses commented on GitHub (Jan 26, 2026):
What if we reuse the existing @@ section from the parsed git patch format?
Here is an example of what git diff returns for me: