forked from mirrors/org-mode
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:
parent
f12f9543fc
commit
815c218f22
|
@ -5503,12 +5503,12 @@ change, as an integer."
|
||||||
(progn
|
(progn
|
||||||
(incf (aref next 2) offset)
|
(incf (aref next 2) offset)
|
||||||
(incf (aref next 3) 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.
|
;; recompute the key of the first element to remove.
|
||||||
;; Otherwise, we need to extend boundaries of robust parents
|
;; Otherwise, extend boundaries of robust parents (see
|
||||||
;; (see `org-element--cache-for-removal'), if any.
|
;; `org-element--cache-for-removal'), if any.
|
||||||
(let ((first-beg (aref next 1)))
|
(let ((first-beg (aref next 1)))
|
||||||
(if (> first-beg beg)
|
(if (>= first-beg beg)
|
||||||
(let ((first (org-element--cache-for-removal beg end offset)))
|
(let ((first (org-element--cache-for-removal beg end offset)))
|
||||||
(when first
|
(when first
|
||||||
(aset next 0 (org-element--cache-key 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
|
;; optional parameter since current modifications are not known
|
||||||
;; yet to the otherwise correct part of the cache (i.e, before
|
;; yet to the otherwise correct part of the cache (i.e, before
|
||||||
;; the first request).
|
;; 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)))
|
(let ((first (org-element--cache-for-removal beg end offset)))
|
||||||
(cond
|
(cond
|
||||||
;; Changes happened before the first known element. Shift
|
;; Changes happened before the first known element. Shift
|
||||||
|
@ -5548,7 +5548,7 @@ change, as an integer."
|
||||||
org-element--cache-sync-requests))
|
org-element--cache-sync-requests))
|
||||||
;; No element to remove. No need to re-parent either.
|
;; No element to remove. No need to re-parent either.
|
||||||
;; Simply shift additional elements, if any, by OFFSET.
|
;; 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
|
;;;; Public Functions
|
||||||
|
|
Loading…
Reference in New Issue