Skip to content

Commit 5587d70

Browse files
authored
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).
2 parents 79f6953 + 6365528 commit 5587d70

File tree

4 files changed

+2
-8
lines changed

4 files changed

+2
-8
lines changed

pkg/gui/context/list_context_trait.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (self *ListContextTrait) FocusLine() {
3030

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

pkg/gui/context/patch_explorer_context.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ func (self *PatchExplorerContext) Render() {
9494
self.c.Render()
9595
}
9696

97-
func (self *PatchExplorerContext) Focus() {
98-
self.FocusSelection()
99-
self.c.Render()
100-
}
101-
10297
func (self *PatchExplorerContext) setContent() {
10398
self.GetView().SetContent(self.GetContentToRender())
10499
}

pkg/gui/patch_exploring/focus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func calculateNewOriginWithNeededAndWantedIdx(currentOrigin int, bufferHeight in
2222
allowedChange := bottom - needToSeeIdx
2323
return origin - min(requiredChange, allowedChange)
2424
} else if wantToSeeIdx >= bottom {
25-
requiredChange := wantToSeeIdx - bottom
25+
requiredChange := wantToSeeIdx + 1 - bottom
2626
allowedChange := needToSeeIdx - origin
2727
return origin + min(requiredChange, allowedChange)
2828
}

pkg/gui/types/context.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ type IPatchExplorerContext interface {
192192
GetIncludedLineIndices() []int
193193
RenderAndFocus()
194194
Render()
195-
Focus()
196195
GetContentToRender() string
197196
NavigateTo(selectedLineIdx int)
198197
GetMutex() *deadlock.Mutex

0 commit comments

Comments
 (0)