mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-05 21:46:49 -04:00
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) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
d4f12ce08c
commit
2cc124a3b1
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user