Makes search insensitive
This commit is contained in:
parent
d17e530667
commit
cb55293bdb
12
page.go
12
page.go
|
@ -123,8 +123,9 @@ func (p *Page) HighlightFoundText() {
|
||||||
if p.SearchTerm == "" {
|
if p.SearchTerm == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
lowS := strings.ToLower(p.SearchTerm)
|
||||||
for i, ln := range p.WrappedContent {
|
for i, ln := range p.WrappedContent {
|
||||||
found := strings.Index(ln, p.SearchTerm)
|
found := strings.Index(strings.ToLower(ln), lowS)
|
||||||
if found < 0 {
|
if found < 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -132,7 +133,8 @@ func (p *Page) HighlightFoundText() {
|
||||||
if bombadillo.Options["theme"] == "inverse" {
|
if bombadillo.Options["theme"] == "inverse" {
|
||||||
format = "\033[27m%s\033[7m"
|
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
|
p.WrappedContent[i] = ln
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,12 +150,14 @@ func (p *Page) FindText() {
|
||||||
if bombadillo.Options["theme"] == "inverse" {
|
if bombadillo.Options["theme"] == "inverse" {
|
||||||
format = "\033[27m%s\033[7m"
|
format = "\033[27m%s\033[7m"
|
||||||
}
|
}
|
||||||
|
lowS := strings.ToLower(s)
|
||||||
for i, ln := range p.WrappedContent {
|
for i, ln := range p.WrappedContent {
|
||||||
found := strings.Index(ln, s)
|
found := strings.Index(strings.ToLower(ln), lowS)
|
||||||
if found < 0 {
|
if found < 0 {
|
||||||
continue
|
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.WrappedContent[i] = ln
|
||||||
p.FoundLinkLines = append(p.FoundLinkLines, i)
|
p.FoundLinkLines = append(p.FoundLinkLines, i)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue