Skip to content

Link the file names in a diffstat to where each file's diff begins - #6044

Open
stefanhaller wants to merge 1 commit into
diff-file-menufrom
jump-to-file-from-diffstat
Open

stefanhaller wants to merge 1 commit into
diff-file-menufrom
jump-to-file-from-diffstat

Conversation

@stefanhaller

Copy link
Copy Markdown
Collaborator

13th PR in the stack of PRs towards staging hunks directly from the main view. This one is stacked on #6043, and it concludes the work.

When selecting a commit, the main view shows its diff with the message first, then a diffstat listing all files changed by this commit, and then the actual diff body. The diffstat reads like a table of contents, and it has always bothered me that it isn't interactive; I always wished I could click on one of the file names to jump to that file in the diff.

Now you can. This PR turns the diffstat entries into clickable links that get underlined as you hover over them, like other hyperlinks in lazygit do. Clicking one scrolls the diff to the beginning of the clicked file, like with the <ctrl-g> menu that was added in the previous PR. If you do this while the commits panel is focused, the focus stays there.

@stefanhaller
stefanhaller added this pull request to stack #6027 September 20, 2026 18:35
@stefanhaller stefanhaller added the enhancement New feature or request label Sep 20, 2026
@stefanhaller
stefanhaller force-pushed the jump-to-file-from-diffstat branch from 0a1e33f to 0fbab84 Compare September 21, 2026 12:45
A diff opens with a diffstat naming every file in it, right above the
diff of each of them. Selecting a commit puts that list in front of you,
naming the same files the menu of the diff's files offers, and the menu
is still the only way to any of them.

Make each of those names a link that goes to where that file's diff
begins, as picking it from the menu does. The panel keeps the focus, so
a file of the commit being read is a click away and the selection stays
on the commit.

The names are found in the output as it is written to the pane, for next
to nothing. The diffstat is git's own text whichever renderer the diff
goes through — delta, diff-so-fancy and difftastic all pass it on
untouched — and it comes first, so the scan for it ends with it and
nothing below is looked at.

The link states the name as the diffstat does, and which file that names
is worked out on the click, against the files the diff turned out to
hold. That is the point at which a name the diffstat cut off behind
"..." or compacted to the "{old => new}" form of a rename can be
recognized at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@stefanhaller
stefanhaller force-pushed the jump-to-file-from-diffstat branch from 0fbab84 to eaac12b Compare September 21, 2026 13:46

This branch has not been deployed

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant