mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-06 13:00:59 -04:00
Extract how far a jump can scroll its target to the top of the view
A jump in a pane that isn't focused is going to stop at the last screenful of the diff as well. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
29942337f5
commit
d198ce56f1
@@ -106,16 +106,21 @@ func (self *DiffLineHelper) PlaceNavigationTarget(
|
||||
}
|
||||
|
||||
// scrollTargetToTop scrolls the given row of the diff to the top of the view, leaving
|
||||
// the view where it is when that row is on screen already. The last screenful of the
|
||||
// diff is as far as it goes, so that the view doesn't scroll past the end of what it is
|
||||
// showing.
|
||||
// the view where it is when that row is on screen already.
|
||||
func (self *DiffLineHelper) scrollTargetToTop(pane types.DiffPaneContext, target int) {
|
||||
view := pane.GetView()
|
||||
originY, height := pane.GetViewTrait().ViewPortYBounds()
|
||||
if target >= originY && target < originY+height {
|
||||
return
|
||||
}
|
||||
view.SetOriginY(min(target, max(0, view.ViewLinesHeight()-height)))
|
||||
pane.GetView().SetOriginY(originYWithTargetAtTop(pane, target))
|
||||
}
|
||||
|
||||
// originYWithTargetAtTop returns the origin that puts the given row of the diff at the
|
||||
// top of the view. The last screenful of the diff is as far as it goes, so that the
|
||||
// view doesn't scroll past the end of what it is showing.
|
||||
func originYWithTargetAtTop(pane types.DiffPaneContext, target int) int {
|
||||
_, height := pane.GetViewTrait().ViewPortYBounds()
|
||||
return min(target, max(0, pane.GetView().ViewLinesHeight()-height))
|
||||
}
|
||||
|
||||
// CollapseNonStickyRange drops a range that only grows while shift is held back to a
|
||||
|
||||
Reference in New Issue
Block a user