org-element--parse-to: Fix return value at the and of first section

* lisp/org-element.el (org-element--parse-to): Fix edge case when
calling `org-element--parse-to' at contents end point of first
section.  We need to return outermost element ending before point in
such scenario.

Fixes https://list.orgmode.org/01bc6137-200d-8e2d-fdd7-6aad8382c619@posteo.eu/T/#u
This commit is contained in:
Ihor Radchenko 2021-11-04 22:54:58 +08:00
parent e4ee04eeae
commit ced2b33357
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 1 additions and 1 deletions

View File

@ -6415,7 +6415,7 @@ If you observe Emacs hangs frequently, please report this to Org mode mailing li
;; the headline section.
(and (org-element--open-end-p element)
(or (= (org-element-property :end element) (point-max))
(and (> pos (org-element-property :contents-end element))
(and (>= pos (org-element-property :contents-end element))
(memq (org-element-type element) '(org-data section headline)))))))
(goto-char (or next cbeg))
(setq mode (if next mode (org-element--next-mode mode type t))