diff --git a/lisp/org-list.el b/lisp/org-list.el index 7a5133dbe..fb061b054 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 1feaf4937..abd1a3c83 100644 --- a/testing/lisp/test-org-list.el +++ b/testing/lisp/test-org-list.el @@ -863,6 +863,11 @@ b. Item 2" (org-test-with-temp-text "1. A\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\n b\n2. c" + (org-insert-item) + (buffer-string)))) ;; Preserve list visibility when inserting an item. (should (equal