Fix bug where occurrence of the pattern in header lines are highlighted

This commit is contained in:
Junegunn Choi 2017-01-11 22:47:26 +09:00
parent 9977a3e9fc
commit 2aa739be81
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -625,7 +625,7 @@ func (t *Terminal) printHeader() {
t.move(line, 2, true) t.move(line, 2, true)
t.printHighlighted(&Result{item: item}, t.printHighlighted(&Result{item: item},
tui.AttrRegular, tui.ColHeader, tui.ColDefault, false) tui.AttrRegular, tui.ColHeader, tui.ColDefault, false, false)
} }
} }
@ -681,14 +681,14 @@ func (t *Terminal) printItem(result *Result, line int, i int, current bool) {
} else { } else {
t.window.CPrint(tui.ColCurrent, t.strong, " ") t.window.CPrint(tui.ColCurrent, t.strong, " ")
} }
t.printHighlighted(result, t.strong, tui.ColCurrent, tui.ColCurrentMatch, true) t.printHighlighted(result, t.strong, tui.ColCurrent, tui.ColCurrentMatch, true, true)
} else { } else {
if selected { if selected {
t.window.CPrint(tui.ColSelected, t.strong, ">") t.window.CPrint(tui.ColSelected, t.strong, ">")
} else { } else {
t.window.Print(" ") t.window.Print(" ")
} }
t.printHighlighted(result, 0, tui.ColNormal, tui.ColMatch, false) t.printHighlighted(result, 0, tui.ColNormal, tui.ColMatch, false, true)
} }
} }
@ -744,7 +744,7 @@ func (t *Terminal) overflow(runes []rune, max int) bool {
return false return false
} }
func (t *Terminal) printHighlighted(result *Result, attr tui.Attr, col1 tui.ColorPair, col2 tui.ColorPair, current bool) { func (t *Terminal) printHighlighted(result *Result, attr tui.Attr, col1 tui.ColorPair, col2 tui.ColorPair, current bool, match bool) {
item := result.item item := result.item
// Overflow // Overflow
@ -752,7 +752,7 @@ func (t *Terminal) printHighlighted(result *Result, attr tui.Attr, col1 tui.Colo
copy(text, item.text.ToRunes()) copy(text, item.text.ToRunes())
matchOffsets := []Offset{} matchOffsets := []Offset{}
var pos *[]int var pos *[]int
if t.merger.pattern != nil { if match && t.merger.pattern != nil {
_, matchOffsets, pos = t.merger.pattern.MatchItem(item, true, t.slab) _, matchOffsets, pos = t.merger.pattern.MatchItem(item, true, t.slab)
} }
charOffsets := matchOffsets charOffsets := matchOffsets