diff --git a/src/search.c b/src/search.c index 29a6fe4ff4f..e4877b5f498 100644 --- a/src/search.c +++ b/src/search.c @@ -2417,8 +2417,10 @@ since only regular expressions have distinguished subexpressions.") } /* Record point, the move (quietly) to the start of the match. */ - if (PT > search_regs.start[sub]) + if (PT >= search_regs.end[sub]) opoint = PT - ZV; + else if (PT > search_regs.start[sub]) + opoint = search_regs.end[sub] - ZV; else opoint = PT;