diff --git a/pkg/gui/controllers/helpers/diff_line_restore.go b/pkg/gui/controllers/helpers/diff_line_restore.go index 24843a396..35a2e4337 100644 --- a/pkg/gui/controllers/helpers/diff_line_restore.go +++ b/pkg/gui/controllers/helpers/diff_line_restore.go @@ -370,7 +370,7 @@ func (self *DiffLineHelper) installDiffLineRestore( // revealed with it stranded at the bottom of a half-filled view. return view.OffscreenLineCount() >= foundLine+viewHeight }, - Apply: func(swapIn func()) bool { + Apply: func(swapIn func()) { bufferLine := foundLine if bufferLine == -1 { if line, ok := findComplete(view.OffscreenDiffLineContents()); ok { @@ -381,14 +381,11 @@ func (self *DiffLineHelper) installDiffLineRestore( swapIn() if bufferLine == -1 { - return false + return } - viewLine, ok := view.ViewLineForBufferLine(bufferLine) - if !ok { - return false + if viewLine, ok := view.ViewLineForBufferLine(bufferLine); ok { + place(viewLine) } - place(viewLine) - return true }, }) } diff --git a/pkg/gui/main_panels.go b/pkg/gui/main_panels.go index 5613525d0..637181f4a 100644 --- a/pkg/gui/main_panels.go +++ b/pkg/gui/main_panels.go @@ -231,10 +231,9 @@ func (gui *Gui) followFocusIntoShownPane(pair types.MainContextPair, panes types // is decided from what is there, and a change line further down would // otherwise be missed. FirstPaintReady: func() bool { return false }, - Apply: func(swapIn func()) bool { + Apply: func(swapIn func()) { swapIn() gui.helpers.DiffLine.EstablishSelection(target, -1) - return false }, }) } diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index 2282906b4..dbc83758a 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -191,10 +191,10 @@ type RenderRestore struct { // while the previous content is still displayed, and the new content is never // drawn at the previous render's scroll position. // - // It must call swapIn either way, and reports whether it placed the view: when - // it didn't, because what it was looking for is not in the new content, the - // task does what it would have done without a restore. - Apply func(swapIn func()) bool + // It must call swapIn even when it finds nothing to place the view on, in which + // case the view keeps the position the paint gave it: the offset it had, or the + // top for content the view hasn't seen. + Apply func(swapIn func()) } // SetRestoreForNextTask arranges for the next command task to put the view back diff --git a/pkg/tasks/tasks_test.go b/pkg/tasks/tasks_test.go index 187b9aed1..7383070e7 100644 --- a/pkg/tasks/tasks_test.go +++ b/pkg/tasks/tasks_test.go @@ -419,14 +419,13 @@ func TestNewCmdTaskRestore(t *testing.T) { manager.SetRestoreForNextTask(&RenderRestore{ // Ready once five lines have loaded — well before the view is filled (30). FirstPaintReady: func() bool { return linesWritten() >= 5 }, - Apply: func(swapIn func()) bool { + Apply: func(swapIn func()) { applyCount++ applyAtLines = linesWritten() swappedBeforeApply = swappedBeforeApply || swapped resetsBeforeApply = getResetOriginCallCount() swapIn() swappedByApply = swapped - return true }, }) @@ -477,10 +476,9 @@ func TestNewCmdTaskRestoreThatFindsNothing(t *testing.T) { manager.SetRestoreForNextTask(&RenderRestore{ FirstPaintReady: func() bool { return false }, - Apply: func(swapIn func()) bool { + Apply: func(swapIn func()) { applyCount++ swapIn() - return false }, }) @@ -520,10 +518,9 @@ func TestRestoreSurvivesTaskReplacement(t *testing.T) { manager.SetRestoreForNextTask(&RenderRestore{ FirstPaintReady: func() bool { return false }, - Apply: func(swapIn func()) bool { + Apply: func(swapIn func()) { applyCount.Add(1) swapIn() - return true }, })