diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 9d70b6e4b..ed4002748 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -44,10 +44,12 @@ func (gui *Gui) linesToReadFromCmdTask(v *gocui.View) tasks.LinesToRead { linesToReadForAccurateScrollbar := min( // However, cap it at some arbitrary max limit, so that we don't get // performance problems for huge monitors or tiny font sizes - height*(height-1)/minScrollbarHeight+oy, 5000) + height*(height-1)/minScrollbarHeight, 5000) + oy return tasks.LinesToRead{ - Total: linesToReadForAccurateScrollbar, + // A view no more than a few lines tall needs fewer lines for its scrollbar + // than it takes to fill it, and the task must read at least those. + Total: max(linesToReadForAccurateScrollbar, linesForFirstRefresh), InitialRefreshAfter: linesForFirstRefresh, } } diff --git a/pkg/integration/tests/main_view/show_another_long_diff_after_scrolling_far_down.go b/pkg/integration/tests/main_view/show_another_long_diff_after_scrolling_far_down.go index 094cb99ba..2f0580663 100644 --- a/pkg/integration/tests/main_view/show_another_long_diff_after_scrolling_far_down.go +++ b/pkg/integration/tests/main_view/show_another_long_diff_after_scrolling_far_down.go @@ -47,9 +47,6 @@ var ShowAnotherLongDiffAfterScrollingFarDown = NewIntegrationTest(NewIntegration SelectedLine(Contains("first commit")) t.Views().Main(). - /* EXPECTED: Content(Contains("diff --git a/first.txt b/first.txt")) - ACTUAL: */ - Content(Contains("diff --git a/second.txt b/second.txt")) }, }) diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index 510fffa49..7e0c10676 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -167,6 +167,11 @@ type LinesToRead struct { // Number of lines after which we have read enough to fill the view, and can // do an initial refresh. Only set for the initial read request; -1 for // subsequent requests. + // + // Unless Total is -1, it must not be more than Total. The task shows nothing + // of what it reads until it has read this many lines or has reached the end + // of its input, so a task that stops reading before then leaves the view + // showing the previous render. InitialRefreshAfter int // Function to call after reading the lines is done