diff options
| author | Matt Armstrong | 2022-10-21 16:07:08 -0700 |
|---|---|---|
| committer | Matt Armstrong | 2022-10-21 16:19:56 -0700 |
| commit | a2fde77b5cc15ec5a1c29ca72c97c806204818a9 (patch) | |
| tree | 52906f65998c7a9280bdfa41ee7d0fbd59dc1dce /src/buffer.c | |
| parent | 37a1145410f7d61883ea689255ee7e564c2fb3d0 (diff) | |
| download | emacs-a2fde77b5cc15ec5a1c29ca72c97c806204818a9.tar.gz emacs-a2fde77b5cc15ec5a1c29ca72c97c806204818a9.zip | |
Fix handling of overlays that begin at END in 'overlays_in'
When passed EMPTY, 'overlays_in' should return empty overlays at END.
It was doing so, but it was also returning any other overlay that
happened to begin at END.
bug#58672
* src/buffer.c (overlays_in): Don't return overlays at END unless they
are empty overlays.
(disable_line_numbers_overlay_at_eob): Pass 'false' instead of 'NULL'
for the bool 'empty' arg.
* test/src/buffer-tests.el (sorted-overlays-in): New helper function.
(test-overlays-in-empty-range): New test exhaustively covering these
edge conditions.
(test-overlays-in-empty-range-bug58672): Simple test for one case.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/buffer.c b/src/buffer.c index 3286cd338ff..fe6b515493e 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -2940,7 +2940,8 @@ the normal hook `change-major-mode-hook'. */) | |||
| 2940 | [BEG, END). | 2940 | [BEG, END). |
| 2941 | 2941 | ||
| 2942 | If EMPTY is true, include empty overlays in that range and also at | 2942 | If EMPTY is true, include empty overlays in that range and also at |
| 2943 | END, provided END denotes the position at the end of the buffer. | 2943 | END, provided END denotes the position at the end of the accessible |
| 2944 | part of the buffer. | ||
| 2944 | 2945 | ||
| 2945 | Return the number found, and store them in a vector in *VEC_PTR. | 2946 | Return the number found, and store them in a vector in *VEC_PTR. |
| 2946 | Store in *LEN_PTR the size allocated for the vector. | 2947 | Store in *LEN_PTR the size allocated for the vector. |
| @@ -2968,7 +2969,7 @@ overlays_in (ptrdiff_t beg, ptrdiff_t end, bool extend, | |||
| 2968 | struct itree_node *node; | 2969 | struct itree_node *node; |
| 2969 | 2970 | ||
| 2970 | ITREE_FOREACH (node, current_buffer->overlays, beg, | 2971 | ITREE_FOREACH (node, current_buffer->overlays, beg, |
| 2971 | /* Find empty OV at Z ? */ | 2972 | /* Find empty OV at ZV ? */ |
| 2972 | (end >= ZV && empty) ? ZV + 1 : ZV, ASCENDING) | 2973 | (end >= ZV && empty) ? ZV + 1 : ZV, ASCENDING) |
| 2973 | { | 2974 | { |
| 2974 | if (node->begin > end) | 2975 | if (node->begin > end) |
| @@ -2985,6 +2986,8 @@ overlays_in (ptrdiff_t beg, ptrdiff_t end, bool extend, | |||
| 2985 | ITREE_FOREACH_ABORT (); | 2986 | ITREE_FOREACH_ABORT (); |
| 2986 | break; | 2987 | break; |
| 2987 | } | 2988 | } |
| 2989 | if (empty && node->begin != node->end) | ||
| 2990 | continue; | ||
| 2988 | } | 2991 | } |
| 2989 | 2992 | ||
| 2990 | if (! empty && node->begin == node->end) | 2993 | if (! empty && node->begin == node->end) |
| @@ -3111,11 +3114,11 @@ disable_line_numbers_overlay_at_eob (void) | |||
| 3111 | 3114 | ||
| 3112 | size = ARRAYELTS (vbuf); | 3115 | size = ARRAYELTS (vbuf); |
| 3113 | v = vbuf; | 3116 | v = vbuf; |
| 3114 | n = overlays_in (ZV, ZV, 0, &v, &size, NULL, NULL); | 3117 | n = overlays_in (ZV, ZV, 0, &v, &size, false, NULL); |
| 3115 | if (n > size) | 3118 | if (n > size) |
| 3116 | { | 3119 | { |
| 3117 | SAFE_NALLOCA (v, 1, n); | 3120 | SAFE_NALLOCA (v, 1, n); |
| 3118 | overlays_in (ZV, ZV, 0, &v, &n, NULL, NULL); | 3121 | overlays_in (ZV, ZV, 0, &v, &n, false, NULL); |
| 3119 | } | 3122 | } |
| 3120 | 3123 | ||
| 3121 | for (i = 0; i < n; ++i) | 3124 | for (i = 0; i < n; ++i) |