mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-26 01:10:23 -04:00
Bring the current search match back into range when the matches change
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
b54318e80c
commit
4c90bc334c
@@ -31,9 +31,6 @@ func TestSearchStatusAfterTheMatchesChange(t *testing.T) {
|
||||
writeLines(v, "match", "other", "other")
|
||||
|
||||
index, total = v.GetSearchStatus()
|
||||
/* EXPECTED:
|
||||
assert.Equal(t, 0, index)
|
||||
ACTUAL: */
|
||||
assert.Equal(t, 2, index)
|
||||
assert.Equal(t, 1, total)
|
||||
}
|
||||
|
||||
@@ -1431,6 +1431,11 @@ func (v *View) updateSearchPositions() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The content may hold fewer matches than it did, so the current one is brought
|
||||
// back into range: readers index the positions by it.
|
||||
v.searcher.currentSearchIndex = min(v.searcher.currentSearchIndex,
|
||||
max(0, len(v.searcher.searchPositions)-1))
|
||||
}
|
||||
|
||||
// IsTainted tells us if the view is tainted
|
||||
|
||||
Reference in New Issue
Block a user