diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2024-01-23 12:17:40 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-01-23 12:19:32 +0900 |
commit | 2a8b65e105ec1a1a9d4cecf947b7267f04453b7c (patch) | |
tree | b78306a81bf6bf33c4b6e2f8dcf7ca0044d6b682 | |
parent | 62a916bc24ce519a414c617737286ae034c1b8e2 (diff) |
Fix highlighting of regions that are matched multiple times
Fix #3596
-rw-r--r-- | src/result.go | 4 | ||||
-rw-r--r-- | src/result_test.go | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/result.go b/src/result.go index d72de420..b0428294 100644 --- a/src/result.go +++ b/src/result.go @@ -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 + } } } diff --git a/src/result_test.go b/src/result_test.go index a930447a..2f818a9b 100644 --- a/src/result_test.go +++ b/src/result_test.go @@ -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{ |