mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 09:14:18 +00:00
Make 'overlays_in' use only real EOB (bug#80242)
This restores the original behavior of 'overlays_in'. Changes in this behavior had been made for cases of narrowing, but this resulted in a regression with uses of 'remove-overlays'. * src/buffer.c (overlays_in): Change all occurrences of ZV to Z. * test/src/buffer-tests.el (test-overlays-in-2) (test-remove-overlays): Adjust expected results to accommodate changes in 'overlays_in'.
This commit is contained in:
parent
adf6c7bcbe
commit
f8a25d00ae
2 changed files with 14 additions and 10 deletions
13
src/buffer.c
13
src/buffer.c
|
|
@ -3082,14 +3082,13 @@ overlays_in (ptrdiff_t beg, ptrdiff_t end, bool extend,
|
|||
{
|
||||
ptrdiff_t idx = 0;
|
||||
ptrdiff_t len = *len_ptr;
|
||||
ptrdiff_t next = ZV;
|
||||
ptrdiff_t next = Z;
|
||||
Lisp_Object *vec = *vec_ptr;
|
||||
struct itree_node *node;
|
||||
|
||||
/* Extend the search range if overlays beginning at ZV are
|
||||
wanted. */
|
||||
ptrdiff_t search_end = ZV;
|
||||
if (end >= ZV && (empty || trailing))
|
||||
/* Extend the search range if overlays beginning at Z are wanted. */
|
||||
ptrdiff_t search_end = Z;
|
||||
if (end >= Z && (empty || trailing))
|
||||
++search_end;
|
||||
|
||||
ITREE_FOREACH (node, current_buffer->overlays, beg, search_end,
|
||||
|
|
@ -3103,7 +3102,7 @@ overlays_in (ptrdiff_t beg, ptrdiff_t end, bool extend,
|
|||
else if (node->begin == end)
|
||||
{
|
||||
next = node->begin;
|
||||
if ((! empty || end < ZV) && beg < end)
|
||||
if ((! empty || end < Z) && beg < end)
|
||||
break;
|
||||
if (empty && node->begin != node->end)
|
||||
continue;
|
||||
|
|
@ -3125,7 +3124,7 @@ overlays_in (ptrdiff_t beg, ptrdiff_t end, bool extend,
|
|||
idx++;
|
||||
}
|
||||
if (next_ptr)
|
||||
*next_ptr = next ? next : ZV;
|
||||
*next_ptr = next ? next : Z;
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1060,7 +1060,9 @@ should evaporate overlays in both."
|
|||
(should-length 2 (overlays-in 1 (point-max)))
|
||||
(should-length 1 (overlays-in (point-max) (point-max)))
|
||||
(narrow-to-region 1 50)
|
||||
(should-length 1 (overlays-in 1 (point-max)))
|
||||
;; We only count empty overlays in narrowed buffers excluding the
|
||||
;; real EOB when the region is confined to `point-max'.
|
||||
(should-length 0 (overlays-in 1 (point-max)))
|
||||
(should-length 1 (overlays-in (point-max) (point-max))))))
|
||||
|
||||
|
||||
|
|
@ -8375,8 +8377,11 @@ dicta sunt, explicabo. "))
|
|||
(should (= (length (overlays-in 1 2)) 0))
|
||||
(narrow-to-region 1 2)
|
||||
;; We've now narrowed, so the zero-length overlay is at the end of
|
||||
;; the (accessible part of the) buffer.
|
||||
(should (= (length (overlays-in 1 2)) 1))
|
||||
;; the (accessible part of the) buffer, but we only count it when
|
||||
;; the region is confined to `point-max'.
|
||||
(should (= (length (overlays-in 1 2)) 0))
|
||||
(should (= (length (overlays-in 2 2)) 1))
|
||||
(should (= (length (overlays-in (point-max) (point-max))) 1))
|
||||
(remove-overlays)
|
||||
(should (= (length (overlays-in (point-min) (point-max))) 0))))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue