jesseduffield / jesseduffield/lazygit

Add sticky diff/hunk header in patch panel when scrolling multi-file/multi-hunk diffs

Open
#5,836 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
82.4k
Forks
3k
Avg merge
2d 18h
Merged PRs (30d)
19

Description

### Is your feature request related to a problem? Please describe.
When viewing a commit's full diff (or a file's diff with several hunks) in the patch panel, scrolling down causes the `diff --git`/`---`/`+++`/`@@ ... @@` header lines to scroll out of view. For large diffs it becomes easy to lose track of which file or which hunk the currently visible lines belong to.

### Describe the solution you'd like
When scrolling the main/patch panel, keep the most recent file header (`--- a/...`, `+++ b/...`) and hunk header (`@@ -x,y +a,b @@ ...`) pinned to the top of the view once it would otherwise scroll off-screen, similar the `context.vim` plugin's `g:context_enabled` behavior in `vim` (see [this example](https://raw.githubusercontent.com/wellle/images/master/context-scroll.gif), but only for file/hunk information, not all code!)

Ideally this would be visually distinguished (e.g. a different background or an underline) so it's clear it's a pinned header and not part of the normal scroll content (see `context.vim` URL above)

### Describe alternatives you've considered
- Selecting each file individually in the commit's file panel keeps the filename visible on the side, but doesn't solve it for multi-hunk single-file diffs, and requires re-selecting per file rather than continuous scrolling.
- Tried using `delta` as a custom formatter for clearer header formatting. It improved readability of individual headers, but didn't solve the underlying issue. It seems since `lazygit` captures pager output as static text and scrolls it itself, so the header still scrolls out of view the same way it does with the built-in diff view.

### Additional context
This would be most useful in the commit view's patch/file-diff panel, but would likely apply anywhere a git diff is rendered in the main panel (staging view, diffing mode, etc

Contributor guide

Open the contributing guide

Research direction

Start with the commit view's patch/file-diff panel, then check the staging view and diffing mode where git diffs are rendered in the main panel. Trace how the patch panel scrolls and identify the current file and hunk headers; done means those headers remain visibly pinned while scrolling multi-file and multi-hunk diffs, with clear visual distinction.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, go
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.