Skip to content

Improve clicking in diff view to enter staging/patch building #3985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

stefanhaller
Copy link
Collaborator

@stefanhaller stefanhaller commented Oct 11, 2024

When using delta with the --hyperlinks --hyperlinks-file-link-format="lazygit-edit://{path}:{line}" option, you can now click on a line that has an underlined line number, and it will take you straight to the staging panel (when you're in the files panel) or the patch building panel (when you're looking at a commit). Previously this was already possible when a single file was selected in the files panel; but it didn't work when a directory was selected, or when looking at the diff of a commit.

This now sits on top of #4429; you can click in the focused main view or hit enter to go to staging/patch-building.

See #3986 for more information.

The implementation is a very rough proof of concept only; don't review the code (yet).

Copy link

codacy-production bot commented Oct 11, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for aa688851 38.11%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (aa68885) Report Missing Report Missing Report Missing
Head commit (983f6f8) 56055 48524 86.56%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3985) 286 109 38.11%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@stefanhaller stefanhaller linked an issue Oct 11, 2024 that may be closed by this pull request
@stefanhaller stefanhaller force-pushed the use-delta-hyperlinks-for-clicking-in-diff branch from 5e84f7e to a20477d Compare October 13, 2024 15:26
@stefanhaller stefanhaller force-pushed the use-delta-hyperlinks-for-clicking-in-diff branch from a20477d to dc9c309 Compare January 3, 2025 09:48
@stefanhaller stefanhaller force-pushed the use-delta-hyperlinks-for-clicking-in-diff branch from dc9c309 to ff1e6a8 Compare February 7, 2025 09:23
@stefanhaller stefanhaller force-pushed the use-delta-hyperlinks-for-clicking-in-diff branch from ff1e6a8 to f6912c8 Compare March 21, 2025 07:13
@stefanhaller stefanhaller mentioned this pull request Mar 28, 2025
7 tasks
@stefanhaller stefanhaller force-pushed the use-delta-hyperlinks-for-clicking-in-diff branch from f6912c8 to 6b1431d Compare March 28, 2025 16:40
@stefanhaller stefanhaller changed the base branch from master to focus-main-view March 28, 2025 16:40
@stefanhaller
Copy link
Collaborator Author

One things that's a little strange is that when looking at the diff of a commit, it takes one click (or enter keypress) to go to patch building, but then it takes two escape presses to get out again. It's weird and takes some getting used to, but I think it's a good price to pay because the feature is so useful. If it bothers us too much we can consider remembering where we came from, and have esc take you all the way out to commits in that case (which may also be confusing though).

@stefanhaller
Copy link
Collaborator Author

If it bothers us too much we can consider remembering where we came from, and have esc take you all the way out to commits in that case

I added a commit that does this, I think I prefer it this way (needs more testing though).

@stefanhaller stefanhaller force-pushed the use-delta-hyperlinks-for-clicking-in-diff branch from b45c992 to bc1cf22 Compare April 1, 2025 21:45
@stefanhaller stefanhaller force-pushed the use-delta-hyperlinks-for-clicking-in-diff branch from bc1cf22 to 15b6116 Compare April 3, 2025 15:33
@stefanhaller stefanhaller force-pushed the use-delta-hyperlinks-for-clicking-in-diff branch from 15b6116 to 678280f Compare April 3, 2025 16:15
@stefanhaller stefanhaller force-pushed the use-delta-hyperlinks-for-clicking-in-diff branch from 678280f to 03f1307 Compare April 10, 2025 09:50
@stefanhaller stefanhaller force-pushed the use-delta-hyperlinks-for-clicking-in-diff branch from 03f1307 to afa3b7f Compare April 16, 2025 14:30
@stefanhaller stefanhaller force-pushed the use-delta-hyperlinks-for-clicking-in-diff branch from afa3b7f to f104a15 Compare April 20, 2025 14:23
Base automatically changed from focus-main-view to master April 21, 2025 16:05
…building

This was already possible, but only when a file was selected, and it woudln't
always land on the right line when a pager was used. Now it's also possible to
do this for directories, and it jumps to the right line.

At the moment this is a hack that relies on delta's hyperlinks, so it only works
on lines that have hyperlinks (added and context).

The implementation is very hacky for other reasons too (e.g. the addition of the
weirdly named ClickedViewRealLineIdx to OnFocusOpts).
… clicked line

This involves first switching to the commit files view, and then entering the
clicked file from there.
…ll the way back out

I *think* I like it better this way, but it needs more testing.
@stefanhaller stefanhaller force-pushed the use-delta-hyperlinks-for-clicking-in-diff branch from f104a15 to 983f6f8 Compare April 21, 2025 16:18
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.

Improve clicking in diff view to enter staging/patch building
1 participant