Skip to content

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

Description

@rgoya

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, 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

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions