]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix `get-pos-property' for the new overlay implementation.
authorMatt Armstrong <matt@rfc20.org>
Sun, 23 Oct 2022 03:48:10 +0000 (20:48 -0700)
committerMatt Armstrong <matt@rfc20.org>
Sun, 23 Oct 2022 03:58:21 +0000 (20:58 -0700)
Some of the trickier edge cases weren't handled properly.  See
bug#58706.

* src/editfns.c (overlays_around): Extend the search range past POS by
one to fetch overlays beginning at POS.  Fetch empty overlays, as they
may be extended by an insertion and thus be relevant to
`get-pos-property'.  Make a note that the function now, unfortunately,
may return out of range overlays.
(Fget_pos_property): Deal with 'overlays_around' returning out of
range overlays.

src/editfns.c

index 0038017585998775782de0a21355bc6baf74d675..c892c02927dd88675ef4a0285b5779ca8fdcc857 100644 (file)
@@ -265,12 +265,20 @@ If you set the marker not to point anywhere, the buffer will have no mark.  */)
 \f
 /* Find all the overlays in the current buffer that touch position POS.
    Return the number found, and store them in a vector in VEC
-   of length LEN.  */
+   of length LEN.
+
+   Note: this can return overlays that do not touch POS.  The caller
+   should filter these out. */
 
 static ptrdiff_t
 overlays_around (ptrdiff_t pos, Lisp_Object *vec, ptrdiff_t len)
 {
-  return overlays_in (pos - 1, pos, false, &vec, &len, false, false, NULL);
+  /* Find all potentially rear-advance overlays at (POS - 1).  Find
+     all overlays at POS, so end at (POS + 1).  Find even empty
+     overlays, which due to the way 'overlays-in' works implies that
+     we might also fetch empty overlays starting at (POS + 1).  */
+  return overlays_in (pos - 1, pos + 1, false, &vec, &len,
+                     true, false, NULL);
 }
 
 DEFUN ("get-pos-property", Fget_pos_property, Sget_pos_property, 2, 3, 0,
@@ -333,7 +341,9 @@ at POSITION.  */)
              if ((OVERLAY_START (ol) == posn
                   && OVERLAY_FRONT_ADVANCE_P (ol))
                  || (OVERLAY_END (ol) == posn
-                     && ! OVERLAY_REAR_ADVANCE_P (ol)))
+                     && ! OVERLAY_REAR_ADVANCE_P (ol))
+                 || OVERLAY_START (ol) > posn
+                 || OVERLAY_END (ol) < posn)
                ; /* The overlay will not cover a char inserted at point.  */
              else
                {