Skip to content

feat: fold individual hunks in the git views - #28

Merged
vasiltop merged 1 commit into
mainfrom
feat/git-hunk-folding
Jul 23, 2026
Merged

feat: fold individual hunks in the git views#28
vasiltop merged 1 commit into
mainfrom
feat/git-hunk-folding

Conversation

@vasiltop

Copy link
Copy Markdown
Owner

Tab only expanded or collapsed a whole file in the git status view, and the diff shown when opening a commit from the log was plain text that Tab couldn't act on at all. Long diffs became a wall of text with no way to focus.

This adds per-hunk folding:

  • Status view: Tab on a file still expands/collapses it into hunks; Tab on a hunk (its @@ header or a body line) now folds just that hunk down to its header, marked with a trailing ..., leaving the other hunks alone.
  • Log-commit diff view: previously unstructured plain text. Its patch is now parsed (via the existing GitParseDiff) into files and hunks so each hunk is foldable, with the commit header and --stat block preserved as a plain preamble. Falls back to raw text if parsing yields nothing.
  • A shared PushHunkLines helper renders hunks identically in both views.

Staging and committing are unchanged — stage a hunk with s, commit the index with c.

Tests

Added git_status_folds_single_hunk and git_diff_view_folds_hunk; full suite passes (698/698). Also verified visually: expanded a file in :git, folded its first hunk, and confirmed the body hid while the next hunk stayed expanded.

Tab only expanded or collapsed a whole file in the status view, and the
diff shown when opening a commit from the log was plain text that Tab
could not act on at all. Both make long diffs a wall of text.

Tab on a hunk now folds just that hunk down to its @@ header (marked with
a trailing " ..."), leaving its siblings alone. The log-commit diff view
gains the same structure: its patch is parsed into files and hunks so
each one is foldable, with the commit header and --stat block kept as a
plain preamble. A shared PushHunkLines helper renders hunks the same way
in both views. Staging and committing are unchanged.
@vasiltop
vasiltop merged commit 5916963 into main Jul 23, 2026
3 checks passed
@vasiltop
vasiltop deleted the feat/git-hunk-folding branch July 23, 2026 23: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