1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-19 00:28:03 +02:00
This commit is contained in:
Jesse Duffield
2021-11-02 21:33:22 +11:00
parent 308a3b51b3
commit 06ca71e955
5 changed files with 11 additions and 7 deletions

View File

@ -218,7 +218,7 @@ func (v *View) SelectSearchResult(index int) error {
}
y := v.searcher.searchPositions[index].y
v.FocusPoint(0, y)
v.FocusPoint(v.ox, y)
if v.searcher.onSelectItem != nil {
return v.searcher.onSelectItem(y, index, itemCount)
}
@ -227,10 +227,9 @@ func (v *View) SelectSearchResult(index int) error {
func (v *View) Search(str string) error {
v.writeMutex.Lock()
defer v.writeMutex.Unlock()
v.searcher.search(str)
v.updateSearchPositions()
if len(v.searcher.searchPositions) > 0 {
// get the first result past the current cursor
currentIndex := 0
@ -243,8 +242,10 @@ func (v *View) Search(str string) error {
}
}
v.searcher.currentSearchIndex = currentIndex
v.writeMutex.Unlock()
return v.SelectSearchResult(currentIndex)
} else {
v.writeMutex.Unlock()
return v.searcher.onSelectItem(-1, -1, 0)
}
}