Extract View.scrollSidewaysToSearchResult

A view that renders only the lines on screen is going to need it once
it has rendered the line of a match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-11-07 20:14:38 +01:00
co-authored by Claude Opus 5.5
parent 74569cf535
commit a73278d246
+9 -4
View File
@@ -540,16 +540,21 @@ func (v *View) SelectSearchResult(index int) {
y := pos.Y
v.FocusPoint(v.ox, y, true)
// A match without a position in the line has nothing to scroll to.
if pos.XStart >= 0 {
v.scrollColumnsIntoView(pos.XStart, pos.XEnd)
}
v.scrollSidewaysToSearchResult(pos)
v.renderSearchStatus(index, itemCount)
if v.searcher.onSelectItem != nil {
v.searcher.onSelectItem(v, y)
}
}
// scrollSidewaysToSearchResult scrolls the view sideways to show the given match if it
// isn't on screen. A match without a position in its line has nothing to scroll to.
func (v *View) scrollSidewaysToSearchResult(pos SearchPosition) {
if pos.XStart >= 0 {
v.scrollColumnsIntoView(pos.XStart, pos.XEnd)
}
}
// Returns <current match index>, <total matches>
func (v *View) GetSearchStatus() (int, int) {
v.refreshSearchPositions()