diff --git a/pkg/gocui/search_test.go b/pkg/gocui/search_test.go index efbc53afd..5e4c60e51 100644 --- a/pkg/gocui/search_test.go +++ b/pkg/gocui/search_test.go @@ -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)) } diff --git a/pkg/gocui/view.go b/pkg/gocui/view.go index 29adf3fc8..fd6b67ce9 100644 --- a/pkg/gocui/view.go +++ b/pkg/gocui/view.go @@ -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