diff --git a/src/buffer.c b/src/buffer.c index 8d90a8088e7..ae04d7a1511 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2363,7 +2363,8 @@ overlays_at (pos, extend, vec_ptr, len_ptr, next_ptr, prev_ptr, change_req) } else if (endpos < pos && endpos > prev) prev = endpos; - else if (endpos == pos && startpos > prev && !change_req) + else if (endpos == pos && startpos > prev + && (!change_req || startpos < pos)) prev = startpos; }