aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorMatt Armstrong2022-10-21 16:07:08 -0700
committerMatt Armstrong2022-10-21 16:19:56 -0700
commita2fde77b5cc15ec5a1c29ca72c97c806204818a9 (patch)
tree52906f65998c7a9280bdfa41ee7d0fbd59dc1dce /test/src
parent37a1145410f7d61883ea689255ee7e564c2fb3d0 (diff)
downloademacs-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 'test/src')
-rw-r--r--test/src/buffer-tests.el45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index 3833f88c5c8..6d5d9913a01 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -937,6 +937,51 @@ with parameters from the *Messages* buffer modification."
937(deftest-overlays-in-1 ae 9 11 (a) (a 10 10)) 937(deftest-overlays-in-1 ae 9 11 (a) (a 10 10))
938(deftest-overlays-in-1 af 10 11 (a) (a 10 10)) 938(deftest-overlays-in-1 af 10 11 (a) (a 10 10))
939 939
940(defun sorted-overlays-in (beg end)
941 (sort
942 (mapcar (lambda (overlay)
943 (list (overlay-start overlay)
944 (overlay-end overlay)))
945 (overlays-in beg end))
946 (lambda (first second)
947 (cl-loop for a in first
948 for b in second
949 thereis (< a b)
950 until (> a b)))))
951
952;; behavior for empty range
953(ert-deftest test-overlays-in-empty-range ()
954 (with-temp-buffer
955 (insert (make-string 4 ?x))
956 (cl-loop for start from (point-min) to (point-max)
957 do (cl-loop for end from start to (point-max)
958 do (when (<= start end)
959 (make-overlay start end))))
960
961 (cl-loop for pos from (point-min) to (point-max)
962 do (ert-info ((format "after (overlay-recenter %d)" pos))
963 (overlay-recenter pos)
964 (should (equal
965 '((1 1))
966 (sorted-overlays-in (point-min) (point-min))))
967 (should (equal
968 '((1 3) (1 4) (1 5) (2 2))
969 (sorted-overlays-in 2 2)))
970 (should (equal
971 '((1 4) (1 5) (2 4) (2 5) (3 3))
972 (sorted-overlays-in 3 3)))
973 (should (equal
974 '((1 5) (2 5) (3 5) (4 4))
975 (sorted-overlays-in 4 4)))
976 (should (equal
977 '((5 5))
978 (sorted-overlays-in (point-max) (point-max))))))))
979
980(ert-deftest test-overlays-in-empty-range-bug58672 ()
981 (with-temp-buffer
982 (insert (make-string 10 ?=))
983 (make-overlay 5 7 nil nil t)
984 (should (equal nil (overlays-in 5 5)))))
940 985
941;; behavior at point-max 986;; behavior at point-max
942(ert-deftest test-overlays-in-2 () 987(ert-deftest test-overlays-in-2 ()