1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-06 22:33:07 +02:00

Fix scrolling hunk into view when selecting next hunk (#4709)

- **PR Description**

If the hunk to be selected was partially scrolled offscreen, the view wouldn't
scroll enough to make it completely visible (the last line of the hunk was still
offscreen).
This commit is contained in:
Stefan Haller
2025-07-07 13:47:58 +02:00
committed by GitHub
4 changed files with 2 additions and 8 deletions

View File

@ -30,7 +30,7 @@ func (self *ListContextTrait) FocusLine() {
// Doing this at the end of the layout function because we need the view to be
// resized before we focus the line, otherwise if we're in accordion mode
// the view could be squashed and won't how to adjust the cursor/origin.
// the view could be squashed and won't know how to adjust the cursor/origin.
// Also, refreshing the viewport needs to happen after the view has been resized.
self.c.AfterLayout(func() error {
oldOrigin, _ := self.GetViewTrait().ViewPortYBounds()

View File

@ -94,11 +94,6 @@ func (self *PatchExplorerContext) Render() {
self.c.Render()
}
func (self *PatchExplorerContext) Focus() {
self.FocusSelection()
self.c.Render()
}
func (self *PatchExplorerContext) setContent() {
self.GetView().SetContent(self.GetContentToRender())
}

View File

@ -22,7 +22,7 @@ func calculateNewOriginWithNeededAndWantedIdx(currentOrigin int, bufferHeight in
allowedChange := bottom - needToSeeIdx
return origin - min(requiredChange, allowedChange)
} else if wantToSeeIdx >= bottom {
requiredChange := wantToSeeIdx - bottom
requiredChange := wantToSeeIdx + 1 - bottom
allowedChange := needToSeeIdx - origin
return origin + min(requiredChange, allowedChange)
}

View File

@ -192,7 +192,6 @@ type IPatchExplorerContext interface {
GetIncludedLineIndices() []int
RenderAndFocus()
Render()
Focus()
GetContentToRender() string
NavigateTo(selectedLineIdx int)
GetMutex() *deadlock.Mutex