소스 검색

org-element: Small fix

* lisp/org-element.el (org-element--cache-submit-request): Fix off by
  one error when updating cache.  Changes happening at the beginning
  to the previous ones, which are always located at the beginning of
  an element, imply to delete previous element.  Also do not call
  `org-element--cache-sync' if there's nothing to synchronize.
Nicolas Goaziou 11 년 전
부모
커밋
815c218f22
1개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 6 6
      lisp/org-element.el

+ 6 - 6
lisp/org-element.el

@@ -5503,12 +5503,12 @@ change, as an integer."
 	(progn
 	  (incf (aref next 2) offset)
 	  (incf (aref next 3) offset)
-	  ;; If last changes happened before old ones, we need to
+	  ;; If last changes happened before (position wise) old ones,
 	  ;; recompute the key of the first element to remove.
-	  ;; Otherwise, we need to extend boundaries of robust parents
-	  ;; (see `org-element--cache-for-removal'), if any.
+	  ;; Otherwise, extend boundaries of robust parents (see
+	  ;; `org-element--cache-for-removal'), if any.
 	  (let ((first-beg (aref next 1)))
-	    (if (> first-beg beg)
+	    (if (>= first-beg beg)
 		(let ((first (org-element--cache-for-removal beg end offset)))
 		  (when first
 		    (aset next 0 (org-element--cache-key first))
@@ -5523,7 +5523,7 @@ change, as an integer."
       ;; optional parameter since current modifications are not known
       ;; yet to the otherwise correct part of the cache (i.e, before
       ;; the first request).
-      (org-element--cache-sync (current-buffer) end offset)
+      (when next (org-element--cache-sync (current-buffer) end offset))
       (let ((first (org-element--cache-for-removal beg end offset)))
 	(cond
 	 ;; Changes happened before the first known element.  Shift
@@ -5548,7 +5548,7 @@ change, as an integer."
 		org-element--cache-sync-requests))
 	 ;; No element to remove.  No need to re-parent either.
 	 ;; Simply shift additional elements, if any, by OFFSET.
-	 (org-element--cache-sync-requests (incf (aref next 3) offset)))))))
+	 (next (incf (aref next 3) offset)))))))
 
 
 ;;;; Public Functions