branch: externals/org
commit 18a146a9d588ce31b1081371d0a1ed9d8c57cce1
Author: Ihor Radchenko <yanta...@posteo.net>
Commit: Ihor Radchenko <yanta...@posteo.net>

    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.kie...@gmail.com>
    Link: 
https://orgmode.org/list/96becf12-9a5a-2fc2-0105-a41528be1...@gmail.com
---
 lisp/org-cycle.el     |  2 +-
 lisp/org-fold-core.el | 11 +++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lisp/org-cycle.el b/lisp/org-cycle.el
index 90fc95f41f..fafcfd7977 100644
--- a/lisp/org-cycle.el
+++ b/lisp/org-cycle.el
@@ -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."
diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el
index 027ff92158..43c6b2b74c 100644
--- a/lisp/org-fold-core.el
+++ b/lisp/org-fold-core.el
@@ -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))
 

Reply via email to