From 4a2a72983f32a875511f26612e7825ef55cf05e5 Mon Sep 17 00:00:00 2001 From: Ali Kefia Date: Wed, 14 Jul 2021 05:37:22 +0200 Subject: [PATCH] Search the last match on line when search back (#2156) --- internal/buffer/search.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/buffer/search.go b/internal/buffer/search.go index ffe1e196..5be3128b 100644 --- a/internal/buffer/search.go +++ b/internal/buffer/search.go @@ -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