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.
This commit is contained in:
Nicolas Goaziou 2014-06-29 17:05:30 +02:00
parent f12f9543fc
commit 815c218f22
1 changed files with 6 additions and 6 deletions

View File

@ -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