diff --git a/src/result.go b/src/result.go index d72de42..b042829 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 a930447..2f818a9 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{