Search the last match on line when search back (#2156)

This commit is contained in:
Ali Kefia 2021-07-14 05:37:22 +02:00 committed by GitHub
parent 33e064b3b9
commit 4a2a72983f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -91,9 +91,10 @@ func (b *Buffer) findUp(r *regexp.Regexp, start, end Loc) ([2]Loc, bool) {
l = util.SliceStart(l, end.X)
}
match := r.FindIndex(l)
all_matches := r.FindAllIndex(l, -1)
if match != nil {
if all_matches != nil {
match := all_matches[len(all_matches)-1]
start := Loc{charpos + util.RunePos(l, match[0]), i}
end := Loc{charpos + util.RunePos(l, match[1]), i}
return [2]Loc{start, end}, true