From 23dd27a97953bab3ffab86dcc83b4e3b139657aa Mon Sep 17 00:00:00 2001 From: Matt Armstrong Date: Sat, 5 Nov 2022 16:31:19 -0700 Subject: [PATCH] itree.c and buffer-tests.el: Incorporate code review feedback * src/itree.c: Improve wording in `itree_insert_gap` comment. * test/src/buffer-tests.el (test-overlay-insert-before-markers-at-start): Don't rely on (point-min) being 1. (test-overlay-insert-before-markers-at-end): ditto. (test-overlay-insert-before-markers-empty): ditto. --- src/itree.c | 4 ++-- test/src/buffer-tests.el | 29 +++++++++++++++++------------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/itree.c b/src/itree.c index 989f452cb92..d73fbffd2b6 100644 --- a/src/itree.c +++ b/src/itree.c @@ -1193,8 +1193,8 @@ itree_iterator_finish (struct itree_iterator *iter) intersecting it, while respecting their rear_advance and front_advance setting. - When BEFORE_MARKERS, all overlays beginning/ending at POS are - treated as if their front_advance/rear_advance was true. */ + If BEFORE_MARKERS is non-zero, all overlays beginning/ending at POS + are treated as if their front_advance/rear_advance was true. */ void itree_insert_gap (struct itree_tree *tree, diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index b11243e021f..26a649e133c 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el @@ -1339,11 +1339,13 @@ Test both front-advance and non-front-advance overlays." (ert-info ((format "front-advance %S" front-advance)) (with-temp-buffer (insert "1234") - (let ((overlay (make-overlay 2 3 nil front-advance nil))) - (goto-char 2) + (let* ((beg (1+ (point-min))) + (end (1+ beg)) + (overlay (make-overlay beg end nil front-advance nil))) + (goto-char beg) (insert-before-markers "x") - (should (equal 3 (overlay-start overlay))) - (should (equal 4 (overlay-end overlay)))))))) + (should (equal (1+ beg) (overlay-start overlay))) + (should (equal (1+ end) (overlay-end overlay)))))))) (ert-deftest test-overlay-insert-before-markers-at-end () "`insert-before-markers' always advances an overlay's end. @@ -1352,22 +1354,25 @@ Test both rear-advance and non-rear-advance overlays." (ert-info ((format "rear-advance %S" rear-advance)) (with-temp-buffer (insert "1234") - (let ((overlay (make-overlay 2 3 nil nil rear-advance))) - (goto-char 3) + (let* ((beg (1+ (point-min))) + (end (1+ beg)) + (overlay (make-overlay beg end nil nil rear-advance))) + (goto-char end) (insert-before-markers "x") - (should (equal 2 (overlay-start overlay))) - (should (equal 4 (overlay-end overlay)))))))) + (should (equal beg (overlay-start overlay))) + (should (equal (1+ end) (overlay-end overlay)))))))) (ert-deftest test-overlay-insert-before-markers-empty () (dolist (advance-args '((nil nil) (t nil) (nil t) (t t))) (ert-info ((format "advance args %S" advance-args)) (with-temp-buffer (insert "1234") - (let ((overlay (apply #'make-overlay 2 2 nil advance-args))) - (goto-char 2) + (let* ((pos (1+ (point-min))) + (overlay (apply #'make-overlay pos pos nil advance-args))) + (goto-char pos) (insert-before-markers "x") - (should (equal 3 (overlay-start overlay))) - (should (equal 3 (overlay-end overlay)))))))) + (should (equal (1+ pos) (overlay-start overlay))) + (should (equal (1+ pos) (overlay-end overlay)))))))) ;; +==========================================================================+ ;; | Moving by deletions -- 2.39.2