瀏覽代碼

org-element: Fix cache bug

* lisp/org-element.el (org-element--cache-sync): Properly remove from
  cache last element in a plain list when blank lines at the end of
  that list are modified.
Nicolas Goaziou 11 年之前
父節點
當前提交
73d60606bd
共有 1 個文件被更改,包括 15 次插入16 次删除
  1. 15 16
      lisp/org-element.el

+ 15 - 16
lisp/org-element.el

@@ -5038,22 +5038,21 @@ removed from the cache."
 		;; Preserve any element ending before BEG.  If it
 		;; overlaps the BEG-END area, remove it.
 		(t
-		 (when (let ((element (car value)))
-			 (or (>= (org-element-property :end element) beg)
-			     ;; Special case: footnote definitions and
-			     ;; plain lists can end with blank lines.
-			     ;; Modifying those can also alter last
-			     ;; element inside.  We must therefore
-			     ;; remove these elements from cache.
-			     (let ((parent
-				    (org-element-property :parent element)))
-			       (and (memq (org-element-type parent)
-					  '(footnote-definition plain-list))
-				    (>= (org-element-property :end parent) beg)
-				    (= (org-element-property :contents-end
-							     parent)
-				       (org-element-property :end element))))))
-		   (remhash key org-element--cache)))))
+		 (let ((element (car value)))
+		   (if (>= (org-element-property :end element) beg)
+		       (remhash key org-element--cache)
+		     ;; Special case: footnote definitions and plain
+		     ;; lists can end with blank lines.  Modifying
+		     ;; those can also alter last element inside.  We
+		     ;; must therefore remove them from cache.
+		     (let ((parent (org-element-property :parent element)))
+		       (when (and parent (eq (org-element-type parent) 'item))
+			 (setq parent (org-element-property :parent parent)))
+		       (when (and parent
+				  (>= (org-element-property :end parent) beg)
+				  (= (org-element-property :contents-end parent)
+				     (org-element-property :end element)))
+			 (remhash key org-element--cache))))))))
 	   org-element--cache)
 	  ;; Signal cache as up-to-date.
 	  (org-element--cache-cancel-changes))))))