Bläddra i källkod

Fix indentation bug

* lisp/org.el (org--get-expected-indentation): Return correct columns
  when at the end of an empty item.
* testing/lisp/test-org.el (test-org/indent-line): Add test.
Nicolas Goaziou 9 år sedan
förälder
incheckning
954103dd9b
2 ändrade filer med 10 tillägg och 2 borttagningar
  1. 5 2
      lisp/org.el
  2. 5 0
      testing/lisp/test-org.el

+ 5 - 2
lisp/org.el

@@ -23004,12 +23004,15 @@ ELEMENT."
 	  ;;
 	  ;; As a special case, if point is at the end of a footnote
 	  ;; definition or an item, indent like the very last element
-	  ;; within.
+	  ;; within.  If that last element is an item, indent like its
+	  ;; contents.
 	  ((and (not (eq type 'paragraph))
 		(let ((cend (org-element-property :contents-end element)))
 		  (and cend (<= cend pos))))
 	   (if (memq type '(footnote-definition item plain-list))
-	       (org--get-expected-indentation (org-element-at-point) nil)
+	       (let ((last (org-element-at-point)))
+		 (org--get-expected-indentation
+		  last (eq (org-element-type last) 'item)))
 	     (goto-char start)
 	     (org-get-indentation)))
 	  ;; In any other case, indent like the current line.

+ 5 - 0
testing/lisp/test-org.el

@@ -644,6 +644,11 @@
 	(goto-char (point-max))
 	(let ((org-adapt-indentation t)) (org-indent-line))
 	(org-get-indentation))))
+  (should
+   (= 4
+      (org-test-with-temp-text "* H\n- A\n  -\n\n<point>"
+	(let ((org-adapt-indentation t)) (org-indent-line))
+	(org-get-indentation))))
   (should
    (zerop
     (org-test-with-temp-text "* H\n- A\n  - AA\n\n\n\n"