emacs-diffs
[Top][All Lists]
Advanced

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

feature/noverlay b865053874: src/textprop.c (get_char_property_and_overl


From: Stefan Monnier
Subject: feature/noverlay b865053874: src/textprop.c (get_char_property_and_overlay): Fix bug#58479
Date: Fri, 14 Oct 2022 16:28:41 -0400 (EDT)

branch: feature/noverlay
commit b86505387480fed81629cbc81cef6b70098bd607
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    src/textprop.c (get_char_property_and_overlay): Fix bug#58479
    
    Correct `get-char-property` which failed to ignore empty overlays.
    
    * src/textprop.c (get_char_property_and_overlay): Make sure the
    overlay covers the character.
    * test/src/buffer-tests.el (buffer-tests--overlay-bug58479): New test.
    * src/buffer.h (buffer_has_overlays): Avoid `interval_tree_size`.
---
 src/buffer.h             | 2 +-
 src/textprop.c           | 3 ++-
 test/src/buffer-tests.el | 8 ++++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/buffer.h b/src/buffer.h
index 288acd4f5e..deb0367d99 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1275,7 +1275,7 @@ INLINE bool
 buffer_has_overlays (void)
 {
   return current_buffer->overlays
-    && (interval_tree_size (current_buffer->overlays) > 0);
+         && (current_buffer->overlays->root != ITREE_NULL);
 }
 
 /* Functions for accessing a character or byte,
diff --git a/src/textprop.c b/src/textprop.c
index 04fae52809..b34246f5bc 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -649,7 +649,8 @@ get_char_property_and_overlay (Lisp_Object position, 
register Lisp_Object prop,
          Lisp_Object tem = Foverlay_get (node->data, prop);
           struct sortvec *this;
 
-         if (NILP (tem) || (w && ! overlay_matches_window (w, node->data)))
+         if (NILP (tem) || node->end < pos + 1
+             || (w && ! overlay_matches_window (w, node->data)))
            continue;
 
           this = (result == items ? items + 1 : items);
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index 9bccbdf2e8..3833f88c5c 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -1340,6 +1340,14 @@ with parameters from the *Messages* buffer modification."
         (overlay-put ov 'value i)))
     (should (eq 9 (get-char-property 1 'value)))))
 
+(ert-deftest buffer-tests--overlay-bug58479 ()
+  (with-temp-buffer
+    (insert "ab")
+    (let* ((pos (+ (point-min) 1))
+           (ol (make-overlay pos pos)))
+      (overlay-put ol 'my-prop 'set)
+      (should (null (get-char-property pos 'my-prop))))))
+
 
 ;; +==========================================================================+
 ;; | Other



reply via email to

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