Skip to content

Commit 93912a6

Browse files
committed
Fixes #1986: evil-open-fold fails to open folds in deeply nested outline/org headers
This commit fixes an issue in evil-mode where, in outline-mode or org-mode, attempting to open a folded section (zo) fails when the cursor is inside a deeply nested header. Previously, the fold would either not expand or expand incorrectly, leaving the nested content hidden and making navigation and editing of deeply nested structures difficult.
1 parent 334a636 commit 93912a6

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

evil-vars.el

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,9 +1843,32 @@ Elements have the form (NAME . FUNCTION).")
18431843
(with-no-warnings (hide-sublevels 1)))
18441844
:toggle outline-toggle-children
18451845
:open ,(lambda ()
1846-
(with-no-warnings
1847-
(show-entry)
1848-
(show-children)))
1846+
(save-excursion
1847+
(let ((func-invisible-p
1848+
(cond
1849+
((and (derived-mode-p 'org-mode)
1850+
(fboundp 'org-invisible-p))
1851+
#'org-invisible-p)
1852+
((and (derived-mode-p 'outline-mode)
1853+
(fboundp 'outline-invisible-p))
1854+
#'outline-invisible-p)
1855+
(t
1856+
#'invisible-p))))
1857+
;; Repeatedly reveal children and body until the entry
1858+
;; is no longer folded
1859+
(while (save-excursion
1860+
(end-of-line)
1861+
(funcall func-invisible-p (point)))
1862+
(save-excursion
1863+
(outline-back-to-heading)
1864+
(with-no-warnings
1865+
(show-children)
1866+
(show-entry))))
1867+
1868+
;; Final pass to guarantee the heading under the cursor
1869+
;; and its body are visible
1870+
(with-no-warnings
1871+
(show-entry)))))
18491872
:open-rec show-subtree
18501873
:close hide-subtree)
18511874
((origami-mode)

0 commit comments

Comments
 (0)