Skip to content

Alt- or shift-click a diff line to open it in your editor - #6041

Open
stefanhaller wants to merge 9 commits into
replace-staging-panels-with-main-viewfrom
edit-diff-line-with-modified-click
Open

stefanhaller wants to merge 9 commits into
replace-staging-panels-with-main-viewfrom
edit-diff-line-with-modified-click

Conversation

@stefanhaller

Copy link
Copy Markdown
Collaborator

10th PR in the stack of PRs towards staging hunks directly from the main view. This one is stacked on #6040.

Alt-click or shift-click a line of any diff and it opens in your editor at that line. It doesn't move the focus or change the selection, and it works while a popup has the focus, so you can read a diff behind a menu and jump into the code. This is especially useful while writing a commit message, when you want to copy a function name from the code that's showing behind the commit message editor.

Both modifier clicks are bound (alt and shift), because no single one works in Ghostty, iTerm2 and VS Code alike. Each of those swallows or rewrites a different one, so you have to test which one works in your terminal.

A 200 ms flash over the clicked row acknowledges the click. An editor can take a moment to appear, and until it does you are otherwise left wondering whether anything happened.

@stefanhaller
stefanhaller added this pull request to stack #6027 September 20, 2026 18:13
@stefanhaller stefanhaller added the enhancement New feature or request label Sep 20, 2026
@stefanhaller
stefanhaller force-pushed the edit-diff-line-with-modified-click branch 2 times, most recently from 138e40d to e3812b1 Compare September 21, 2026 13:46
@stefanhaller
stefanhaller force-pushed the edit-diff-line-with-modified-click branch 3 times, most recently from 2963608 to 887ab6d Compare September 27, 2026 10:41
@stefanhaller
stefanhaller force-pushed the edit-diff-line-with-modified-click branch from 887ab6d to c03184c Compare September 27, 2026 10:56
@stefanhaller
stefanhaller force-pushed the edit-diff-line-with-modified-click branch from c03184c to 020991c Compare September 27, 2026 16:27
stefanhaller and others added 9 commits October 1, 2026 17:28
These always returned nil.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
View.SetHighlight has no production callers.
A view can need repainting even when its cached wrapping is still valid.
Track that state independently so content-only flushes do not overload
tainted, whose only job is to request a viewLines rebuild.
Mouse events on views behind a popup are normally swallowed before their
bindings can run. Add an explicit early-dispatch opt-in for actions that
should remain live there, matching the phase where hyperlink clicks
already run.
The selected-line keybinding and a modified click need the same path
from a rendered diff row to the editor. Give that operation an explicit
view-line argument before adding the mouse gesture.
Bindings match modifiers exactly, so a modified press must not turn into
an unmodified drag or release halfway through the gesture. Capture the
press-time modifiers once and carry them until the button is released.

This also makes unbound modified clicks no-ops instead of silently
invoking plain-click behavior.
Clickable renderer gutters are small and unavailable on some diff rows.
Make the whole row an editor target without changing focus or selection,
including while a popup is focused.

Use both Alt and Shift because terminal mouse protocols do not deliver
either modifier consistently across Ghostty, iTerm2, and VS Code.
Actions that hand control to another application need visible
acknowledgement without moving a view's cursor or replacing renderer
colors. Reverse the narrow selection bar independently of selection
state, and clear transient flashes whenever the terminal UI suspends.
Non-suspending graphical editors can take a moment to reach the
foreground, leaving a modified click with no visible response. Briefly
reverse the clicked row's selection bar after launching the editor so
the registered action is apparent.

Arm the flash only for a resolved diff row, keep newer clicks safe from
stale timers, and rely on suspension to clear the transient state before
terminal editors take over.
@stefanhaller
stefanhaller force-pushed the edit-diff-line-with-modified-click branch from 020991c to e3f9bfa Compare October 1, 2026 15:28

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