From: Stefan Monnier Date: Fri, 14 Oct 2022 20:28:33 +0000 (-0400) Subject: src/textprop.c (get_char_property_and_overlay): Fix bug#58479 X-Git-Tag: emacs-29.0.90~1616^2~406^2~14 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b86505387480fed81629cbc81cef6b70098bd607;p=emacs.git 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`. --- diff --git a/src/buffer.h b/src/buffer.h index 288acd4f5ee..deb0367d990 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 04fae528097..b34246f5bc7 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 9bccbdf2e89..3833f88c5c8 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