mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-05 21:46:49 -04:00
Stop a render restore saying whether it placed the view
Nothing has read that since the paint started settling the scroll position before consulting the restore: what the answer was for was deciding whether the reset the new content was owed still had to happen, and by then it has. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
739412cd5f
commit
a0af7275af
@@ -376,7 +376,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 {
|
||||
@@ -387,14 +387,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
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
+4
-4
@@ -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
|
||||
|
||||
@@ -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
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user