diff --git a/page.go b/page.go index 08e75fb..32a62cf 100644 --- a/page.go +++ b/page.go @@ -123,8 +123,9 @@ func (p *Page) HighlightFoundText() { if p.SearchTerm == "" { return } + lowS := strings.ToLower(p.SearchTerm) for i, ln := range p.WrappedContent { - found := strings.Index(ln, p.SearchTerm) + found := strings.Index(strings.ToLower(ln), lowS) if found < 0 { continue } @@ -132,7 +133,8 @@ func (p *Page) HighlightFoundText() { if bombadillo.Options["theme"] == "inverse" { format = "\033[27m%s\033[7m" } - ln = strings.Replace(ln, p.SearchTerm, fmt.Sprintf(format, p.SearchTerm), -1) + foundS := ln[found:found+len(lowS)] + ln = strings.Replace(ln, foundS, fmt.Sprintf(format, foundS), -1) p.WrappedContent[i] = ln } } @@ -148,12 +150,14 @@ func (p *Page) FindText() { if bombadillo.Options["theme"] == "inverse" { format = "\033[27m%s\033[7m" } + lowS := strings.ToLower(s) for i, ln := range p.WrappedContent { - found := strings.Index(ln, s) + found := strings.Index(strings.ToLower(ln), lowS) if found < 0 { continue } - ln = strings.Replace(ln, s, fmt.Sprintf(format, s), -1) + foundS := ln[found:found+len(lowS)] + ln = strings.Replace(ln, foundS, fmt.Sprintf(format, foundS), -1) p.WrappedContent[i] = ln p.FoundLinkLines = append(p.FoundLinkLines, i) }