summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2014-01-11 21:31:53 (GMT)
committer Nicolas Goaziou <n.goaziou@gmail.com>2014-01-11 21:31:53 (GMT)
commitfd5edd35ae33ef9fbd15a8e4413455ce99f96007 (patch)
tree478731141ed7ab6d044b89cb71ee6fc266594ee5
parenta4b1fa7ca1bf63075c29a89f1379a4726313db68 (diff)
downloadorg-mode-fd5edd35ae33ef9fbd15a8e4413455ce99f96007.zip
org-mode-fd5edd35ae33ef9fbd15a8e4413455ce99f96007.tar.gz
org-element: Fix cache bug
* lisp/org-element.el (org-element-cache-get): Return correct cached element when point is at the beginning of an item.
-rw-r--r--lisp/org-element.el19
1 files changed, 12 insertions, 7 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index fdcbf8d..511468e 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -5602,14 +5602,19 @@ cache, unless optional argument IGNORE-CHANGES is non-nil."
(cond
((< key beg)
(setq node (avl-tree--node-left node)))
- ((= key beg)
- (if (memq (org-element-type element) '(item table-row))
- (setq last (avl-tree--node-data node)
- node (avl-tree--node-left node))
- (throw 'found (avl-tree--node-data node))))
- (t
+ ((> key beg)
+ (setq last (avl-tree--node-data node)
+ node (avl-tree--node-right node)))
+ ;; When KEY is at the beginning of a table or list,
+ ;; make sure to return it instead of the first row or
+ ;; item.
+ ((and (memq (org-element-type element) '(item table-row))
+ (= (org-element-property
+ :contents-begin (org-element-property :parent element))
+ beg))
(setq last (avl-tree--node-data node)
- node (avl-tree--node-right node))))))
+ node (avl-tree--node-left node)))
+ (t (throw 'found (avl-tree--node-data node))))))
last)))))
(defun org-element-cache-put (data &optional element)