From a2dd3327eb386bb71fd6bd0278e7da4cda98b6c2 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 24 Sep 2026 21:55:40 +0200 Subject: [PATCH] Check the line we start on when navigating to a list item NavigateToLine looks for its target among the lines the view has rendered. When a list is scrolled, the view holds only the part of it that is on screen, so the target may not be among them. For that case the helper jumps to the top of the list and walks down instead. That walk presses a key before it looks, so it never sees the item it starts on, which after jumping is the first item of the list. A target sitting there is reported as missing. The shorter the terminal, the more of a list is scrolled out of view and the more often that walk is needed, so this surfaced once the demos began running in a 35 line terminal. Check the line the walk starts on before moving off it. Co-Authored-By: Claude Opus 5 (1M context) --- pkg/integration/components/view_driver.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/integration/components/view_driver.go b/pkg/integration/components/view_driver.go index 818385ca1..b5168487a 100644 --- a/pkg/integration/components/view_driver.go +++ b/pkg/integration/components/view_driver.go @@ -905,6 +905,14 @@ func (self *ViewDriver) NavigateToLine(matcher *TextMatcher) *ViewDriver { keyPress = func() { self.SelectPreviousItem() } } + // The loop below only looks at the lines it moves onto, so the line we are + // starting from has to be checked here. After jumping to the top that line + // is the first item of the list, and for a list we had to scroll through + // it is a plausible target. + if ok, _ := matcher.test(view.BufferLines()[selectedLineIdx]); ok { + return self + } + for range maxNumKeyPresses { keyPress() idx := self.getSelectedLineIdx()