branch: externals/org
commit e4504853b514185cf776db893103a25b3912d034
Merge: 9fd547dd3a 27a41d418d
Author: Ihor Radchenko <yanta...@posteo.net>
Commit: Ihor Radchenko <yanta...@posteo.net>

    Merge branch 'bugfix'
---
 lisp/org-element.el              | 14 +-------------
 testing/lisp/test-org-element.el | 27 ++++++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index a104d540e6..f197e34a94 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 92fd630781..92047bfd7e 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
+<point>** 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)
 

Reply via email to