From a73278d2467d2b504baccc57798817fbb13aa0b0 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 7 Nov 2026 17:49:28 +0100 Subject: [PATCH] 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 --- pkg/gocui/view.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/gocui/view.go b/pkg/gocui/view.go index 643163a2a..dbb33c8b4 100644 --- a/pkg/gocui/view.go +++ b/pkg/gocui/view.go @@ -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 , func (v *View) GetSearchStatus() (int, int) { v.refreshSearchPositions()