mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-12 15:53:33 -04:00
Show the current search match in full where it overlaps other matches
If the search string can overlap itself, as "aa" can in "aaaa", the matches overlap too. A cell that is part of two matches shows as part of the first one. If the second one is the current match, some of its cells then show in the color of the other matches, and it is hard to tell where the current match is. Show a cell as part of the current match whenever it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e64b209aed
commit
b9e0861dfc
@@ -126,7 +126,7 @@ func TestDrawSearchMatches(t *testing.T) {
|
||||
drawSearchHighlights(v))
|
||||
}
|
||||
|
||||
// Where matches overlap, a cell is highlighted as part of the first match it is in.
|
||||
// Where matches overlap, the current one shows in full.
|
||||
func TestDrawOverlappingSearchMatches(t *testing.T) {
|
||||
WithSimulationScreen(t, 14, 6)
|
||||
|
||||
@@ -139,7 +139,7 @@ func TestDrawOverlappingSearchMatches(t *testing.T) {
|
||||
assert.Equal(t, 3, total)
|
||||
|
||||
assert.Equal(t,
|
||||
[]string{"##*#......"},
|
||||
[]string{"#**#......"},
|
||||
drawSearchHighlights(v))
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -2178,7 +2178,8 @@ func (s *searcher) matchWalker(firstY int) searchMatchWalker {
|
||||
}
|
||||
|
||||
// matchAt returns whether the cell at content column x of view line y is part of a
|
||||
// search match.
|
||||
// search match. If it is part of several overlapping matches, and the current match is
|
||||
// one of them, it counts as part of the current one.
|
||||
func (w *searchMatchWalker) matchAt(x, y int) searchMatch {
|
||||
for w.index < len(w.positions) {
|
||||
pos := w.positions[w.index]
|
||||
@@ -2191,7 +2192,7 @@ func (w *searchMatchWalker) matchAt(x, y int) searchMatch {
|
||||
if w.index == len(w.positions) || !w.positions[w.index].contains(x, y) {
|
||||
return noSearchMatch
|
||||
}
|
||||
if w.index == w.currentIndex {
|
||||
if w.positions[w.currentIndex].contains(x, y) {
|
||||
return currentSearchMatch
|
||||
}
|
||||
return otherSearchMatch
|
||||
|
||||
Reference in New Issue
Block a user