diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-07-06 12:05:18 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-07-06 12:05:18 +0200 |
commit | 07a4a728628776202d58a48436da9f710e11cb8e (patch) | |
tree | 9883625b5219e76c0d246583ee3b86d4cf69b7de | |
parent | c78db891060ea91aabed23d91234532729e3b705 (diff) | |
download | org-mode-07a4a728628776202d58a48436da9f710e11cb8e.tar.gz |
list: Fix regression when inserting items
* lisp/org-list.el (org-list-insert-item): Fix splitting item.
* testing/lisp/test-org-list.el (test-org-list/insert-item): Add test.
Reported-by: Duianto - <otnaiud@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-07/msg00061.html>
-rw-r--r-- | lisp/org-list.el | 6 | ||||
-rw-r--r-- | testing/lisp/test-org-list.el | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el index 7a5133d..fb061b0 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -1330,14 +1330,14 @@ This function modifies STRUCT." ;; This means that the part between body start of body and ;; split point was removed. So we compute the offset and ;; shift item's positions accordingly. In any other case, - ;; the item was simply shifted by ITEM-SIZE. + ;; the item was simply shifted by SIZE-OFFSET. ((and split-line-p (not beforep) (>= p pos) (<= p item-end-no-blank)) (let ((offset (- pos item ind (length bullet) (length after-bullet)))) (setcar e (- p offset)) (setcar (nthcdr 6 e) (- end offset)))) (t - (setcar e (+ p item-size)) - (setcar (nthcdr 6 e) (+ end item-size)))))) + (setcar e (+ p size-offset)) + (setcar (nthcdr 6 e) (+ end size-offset)))))) (push (list item ind bullet nil box nil (+ item item-size)) struct) (setq struct (sort struct #'car-less-than-car)) ;; If not BEFOREP, new item must appear after ITEM, so exchange diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el index 1feaf49..abd1a3c 100644 --- a/testing/lisp/test-org-list.el +++ b/testing/lisp/test-org-list.el @@ -863,6 +863,11 @@ b. Item 2<point>" (org-test-with-temp-text "1. A<point>\n\n2. \n\n3. B" (org-insert-item) (buffer-string)))) + (should + (equal "1. a\n2. \n b\n3. c" + (org-test-with-temp-text "1. a<point>\n b\n2. c" + (org-insert-item) + (buffer-string)))) ;; Preserve list visibility when inserting an item. (should (equal |