Carry hunk mode into the other pane on a cross-pane click

Clicking the staged/unstaged pane you weren't focused on selected a single
line the first time, even in hunk mode, because that pane's select mode was
still its default until it had been focused once (tabbing to it and back was
the workaround). Seed the clicked pane's mode from the one we're leaving so
the very first click there behaves like every later one.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller 2026-06-20 17:13:45 +02:00
parent 0aab64e362
commit e03f4b1321

View file

@ -977,6 +977,12 @@ func (self *MainViewController) editClickedLine(opts gocui.ViewMouseBindingOpts)
}
func (self *MainViewController) onClickInOtherViewOfMainViewPair(opts gocui.ViewMouseBindingOpts) error {
// Carry the select mode over from the pane we're leaving, so clicking into the
// other pane keeps hunk mode even the first time we enter it — without this its
// mode would still be the default single line until it had been focused at least
// once (e.g. by tabbing to it). selectClickedDiffLine then preserves or collapses
// that mode depending on where we clicked.
*self.context.DiffSelectState() = *self.otherContext.DiffSelectState()
self.c.Context().Push(self.context, types.OnFocusOpts{})
return self.selectClickedDiffLine(opts)
}