From 789303d9f14a79bf04ff3105a7fd8b46b52eff7b Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 22 Dec 2025 16:12:31 +0100 Subject: [PATCH] Add scrollIntoView parameter to FocusPoint --- view.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/view.go b/view.go index 70cbd973..87f61eeb 100644 --- a/view.go +++ b/view.go @@ -262,7 +262,7 @@ func (v *View) SelectSearchResult(index int) error { y := v.searcher.searchPositions[index].Y - v.FocusPoint(v.ox, y) + v.FocusPoint(v.ox, y, true) if v.searcher.onSelectItem != nil { return v.searcher.onSelectItem(y, index, itemCount) } @@ -325,14 +325,17 @@ func (v *View) IsSearching() bool { return v.searcher.searchString != "" } -func (v *View) FocusPoint(cx int, cy int) { +func (v *View) FocusPoint(cx int, cy int, scrollIntoView bool) { lineCount := len(v.lines) if cy < 0 || cy > lineCount { return } - height := v.InnerHeight() - v.oy = calculateNewOrigin(cy, v.oy, lineCount, height) + if scrollIntoView { + height := v.InnerHeight() + v.oy = calculateNewOrigin(cy, v.oy, lineCount, height) + } + v.cx = cx v.cy = cy - v.oy }