瀏覽代碼

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>
Nicolas Goaziou 4 年之前
父節點
當前提交
07a4a72862
共有 2 個文件被更改,包括 8 次插入3 次删除
  1. 3 3
      lisp/org-list.el
  2. 5 0
      testing/lisp/test-org-list.el

+ 3 - 3
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

+ 5 - 0
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