Skip to content

Commit

Permalink
Fix highlighting of regions that are matched multiple times
Browse files Browse the repository at this point in the history
Fix #3596
  • Loading branch information
junegunn committed Jan 23, 2024
1 parent 62a916b commit 2a8b65e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ func (result *Result) colorOffsets(matchOffsets []Offset, theme *tui.ColorTheme,
for i := off[0]; i < off[1]; i++ {
// Negative of 1-based index of itemColors
// - The extra -1 means highlighted
cols[i] = cols[i]*-1 - 1
if cols[i] >= 0 {
cols[i] = cols[i]*-1 - 1
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestColorOffset(t *testing.T) {
// ++++++++ ++++++++++
// --++++++++-- --++++++++++---

offsets := []Offset{{5, 15}, {25, 35}}
offsets := []Offset{{5, 15}, {10, 12}, {25, 35}}
item := Result{
item: &Item{
colors: &[]ansiOffset{
Expand Down

0 comments on commit 2a8b65e

Please sign in to comment.