mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 16:44:23 +08:00
This commit is contained in:
1 parent
a5c6ac8f03
commit
9bde9eec64
3 files changed
+40
-33
No files matched your search
+4
-1
@@ -84,13 +84,16 @@ func (p *PageText) Search(query string) []TextMatch {
|
||||
length := utf8.RuneCountInString(query)
|
||||
for index, run := range p.Runs {
|
||||
text := foldText(run.Text)
|
||||
runes := []rune(run.Text)
|
||||
var runes []rune
|
||||
codeOffset := 0
|
||||
for offset := 0; offset < len(text); {
|
||||
found := strings.Index(text[offset:], query)
|
||||
if found < 0 {
|
||||
break
|
||||
}
|
||||
if runes == nil {
|
||||
runes = []rune(run.Text)
|
||||
}
|
||||
start := codeOffset + utf8.RuneCountInString(text[offset:offset+found])
|
||||
offset += found
|
||||
end := start + length
|
||||
|
||||
Reference in new issue
Block a user