Speed up search and replace

Ref #625
This commit is contained in:
Zachary Yedidia
2017-04-16 11:11:04 -04:00
parent 8168a75bde
commit 007b060cbd
2 changed files with 38 additions and 11 deletions

View File

@@ -565,6 +565,7 @@ func Replace(args []string) {
}
}
} else {
var deltas []Delta
for i := 0; i < view.Buf.LinesNum(); i++ {
// view.Buf.lines[i].data = regex.ReplaceAll(view.Buf.lines[i].data, []byte(replace))
matches := regex.FindAllIndex(view.Buf.lines[i].data, -1)
@@ -574,11 +575,13 @@ func Replace(args []string) {
from := Loc{m[0], i}
to := Loc{m[1], i}
view.Buf.Replace(from, to, replace)
deltas = append(deltas, Delta{replace, from, to})
// view.Buf.Replace(from, to, replace)
found++
}
}
}
view.Buf.MultipleReplace(deltas)
}
view.Cursor.Relocate()