Scroll a newly conflicted commit into view in background refreshes

When a refresh finds a new conflicted commit, it selects it so that the
user sees where the rebase stopped. A background refresh keeps the
scroll position of the views it updates though. If the conflicted
commit is outside the visible part of the commits view, the selection
moves to a commit that the user can't see.

Scroll the selection into view whenever the refresh moves it to a newly
conflicted commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-10-30 20:37:56 +01:00
co-authored by Claude Opus 5.5
parent 30744324f8
commit 550a6d88a7
2 changed files with 8 additions and 4 deletions
@@ -906,7 +906,14 @@ func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState,
// The caller set the selection index deliberately; leave it untouched.
}
self.rerenderView(self.c.Contexts().LocalCommits, env.focusOpts())
focusOpts := env.focusOpts()
if newConflictedCommitIdx != nil {
// We selected a commit that the user needs to look at next, so
// scroll it into view even if the refresh keeps the scroll position
// otherwise.
focusOpts.KeepScrollPosition = false
}
self.rerenderView(self.c.Contexts().LocalCommits, focusOpts)
})
return nil
@@ -31,10 +31,7 @@ var BackgroundRefreshScrollsToConflictedCommit = NewIntegrationTest(NewIntegrati
}).
// The conflicted commit, below the 30 pending todos and their header
SelectedLineIdx(31).
/* EXPECTED:
SelectedLineIsVisible().
SelectedLine(Contains("<-- CONFLICT --- this will conflict"))
ACTUAL: */
OriginY(0)
},
})