emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/noverlay b78be2bf7a 3/4: Fix `get-pos-property' for the new over


From: Stefan Monnier
Subject: feature/noverlay b78be2bf7a 3/4: Fix `get-pos-property' for the new overlay implementation.
Date: Mon, 24 Oct 2022 12:59:49 -0400 (EDT)

branch: feature/noverlay
commit b78be2bf7a9ac8b71d25529d5736373f51852c36
Author: Matt Armstrong <matt@rfc20.org>
Commit: Matt Armstrong <matt@rfc20.org>

    Fix `get-pos-property' for the new overlay implementation.
    
    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 | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/editfns.c b/src/editfns.c
index 0038017585..c892c02927 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -265,12 +265,20 @@ If you set the marker not to point anywhere, the buffer 
will have no mark.  */)
 
 /* 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
                {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]