org-fold-core-previous-visibility-change: Fix edge case

* lisp/org-fold-core.el (org-fold-core-next-visibility-change): Take
into account that `previous-single-char-property-change' move the
point to the first position where the property is still unchanged.
* lisp/org-cycle.el (org-cycle-set-visibility-according-to-property):
Ignore invisibility when skipping subtree.

Reported-by: Philipp Kiefer <phil.kiefer@gmail.com>
Link: https://orgmode.org/list/96becf12-9a5a-2fc2-0105-a41528be1f66@gmail.com
This commit is contained in:
Ihor Radchenko 2023-02-17 14:58:32 +03:00
parent 715f74db36
commit 18a146a9d5
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 10 additions and 3 deletions

View File

@ -658,7 +658,7 @@ With a numeric prefix, show all headlines up to that level."
((or "all" "showall")
(org-fold-show-subtree))
(_ nil)))
(org-end-of-subtree)))))))
(org-end-of-subtree t)))))))
(defun org-cycle-overview ()
"Switch to overview mode, showing only top-level headlines."

View File

@ -835,13 +835,20 @@ If PREVIOUS-P is non-nil, search backwards."
(next-change (if previous-p
(if ignore-hidden-p
(lambda (p) (org-fold-core-previous-folding-state-change (org-fold-core-get-folding-spec nil p) p limit))
(lambda (p) (max limit (1- (previous-single-char-property-change p 'invisible nil limit)))))
(lambda (p) (max limit (previous-single-char-property-change p 'invisible nil limit))))
(if ignore-hidden-p
(lambda (p) (org-fold-core-next-folding-state-change (org-fold-core-get-folding-spec nil p) p limit))
(lambda (p) (next-single-char-property-change p 'invisible nil limit)))))
(next pos))
(while (and (funcall cmp next limit)
(not (org-xor invisible-initially? (funcall invisible-p next))))
(not (org-xor
invisible-initially?
(funcall invisible-p
(if previous-p
;; NEXT-1 -> NEXT is the change.
(max limit (1- next))
;; NEXT -> NEXT+1 is the change.
next)))))
(setq next (funcall next-change next)))
next))