diff --git a/lisp/org-element.el b/lisp/org-element.el index a104d540e..f197e34a9 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -6812,19 +6812,7 @@ The function returns the new value of `org-element--cache-change-warning'." (setq org-element--cache-last-buffer-size (buffer-size)) (goto-char beg) (forward-line 0) - (let ((bottom (save-excursion - (goto-char end) - (if (and (bolp) - ;; When beg == end, still extent to eol. - (> (point) beg)) - ;; FIXME: Potential pitfall. - ;; We are appending to an element end. - ;; Unless the last inserted char is not - ;; newline, the next element is not broken - ;; and does not need to be purged from the - ;; cache. - end - (line-end-position))))) + (let ((bottom (save-excursion (goto-char end) (line-end-position)))) (prog1 ;; Use the worst change warning to not miss important edits. ;; This function is called before edit and after edit by diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 92fd63078..92047bfd7 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -5194,7 +5194,32 @@ paragraph (let ((org-element-use-cache t)) (org-element-at-point (point-max)) (delete-region (point) (point-max)) - (should (eq 'paragraph (org-element-type (org-element-at-point))))))) + (should (eq 'paragraph (org-element-type (org-element-at-point)))))) + ;; Remove/re-introduce heading. + (org-test-with-temp-text + " +* 1 +** 1-1 +a +** 1-2 +a +" + (let ((org-element-use-cache t)) + (org-element-at-point (point-max)) + (insert "FOO") + (should + (equal + "1-1" + (org-element-property + :title + (org-element-lineage (org-element-at-point) '(headline))))) + (insert "\n") + (should + (equal + "1" + (org-element-property + :title + (org-element-lineage (org-element-at-point) '(headline)))))))) (provide 'test-org-element)