Explorar o código

org-element: Fix cache when point is at eob

* lisp/org-element.el (org-element-at-point): Fix cache when point is
  at eob and shortcut found something above.
Nicolas Goaziou %!s(int64=11) %!d(string=hai) anos
pai
achega
fde42c5303
Modificáronse 1 ficheiros con 7 adicións e 8 borrados
  1. 7 8
      lisp/org-element.el

+ 7 - 8
lisp/org-element.el

@@ -5252,20 +5252,19 @@ first row."
 		 ;; check.  Otherwise, move at top level and start
 		 ;; parsing right after its broader ancestor.
 		 (let ((cache-end (org-element-property :end cached)))
-		   (if (or (> cache-end origin)
-			   (and (= cache-end origin) (= (point-max) origin)))
+		   (if (> cache-end origin)
 		       (setq element cached
 			     parent (org-element-property :parent cached)
 			     end cache-end)
 		     (goto-char cache-end)
-		     (let ((up cached))
+		     (let ((up cached) (last cached))
 		       (while (and (setq up (org-element-property :parent up))
 				   (<= (org-element-property :end up) origin))
-			 (goto-char (org-element-property :end up)))
-		       (when up
-			 (setq element up
-			       parent (org-element-property :parent up)
-			       end (org-element-property :end up))))))
+			 (goto-char (org-element-property :end up))
+			 (setq last up))
+		       (setq element (or up last)
+			     parent (org-element-property :parent up)
+			     end (org-element-property :end up)))))
 		 (throw 'loop nil)))))
 	 ;; Opportunistic search failed.  Move back to beginning of
 	 ;; section in current headline, if any, or to first non-empty