Skip to content

Commit d8a4bb5

Browse files
committed
feat: Ensure indicators is refreshed after show/hide
1 parent 8972eb6 commit d8a4bb5

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

treesit-fold.el

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,14 @@ This function is borrowed from `tree-sitter-node-at-point'."
345345
(overlay-put ov 'modification-hooks '(treesit-fold--on-change))
346346
(overlay-put ov 'insert-in-front-hooks '(treesit-fold--on-change))
347347
(overlay-put ov 'isearch-open-invisible #'treesit-fold--on-change)
348-
(overlay-put ov 'isearch-open-invisible-temporary
349-
(lambda (ov hide-p)
350-
(if hide-p (treesit-fold--hide-ov ov)
351-
(treesit-fold--show-ov ov))))
348+
(overlay-put ov 'isearch-open-invisible-temporary #'treesit-fold--open-invisible-temporary)
352349
ov)))
353350

351+
(defun treesit-fold--open-invisible-temporary (ov hide-p)
352+
"Temporary show/hide OV depends on HIDE-P flag."
353+
(if hide-p (treesit-fold--hide-ov ov)
354+
(treesit-fold--show-ov ov)))
355+
354356
(defun treesit-fold--on-change (ov &rest _)
355357
"Open overlay OV during content is changed."
356358
(delete-overlay ov))
@@ -359,7 +361,8 @@ This function is borrowed from `tree-sitter-node-at-point'."
359361
"Show the OV."
360362
(overlay-put ov 'invisible nil)
361363
(overlay-put ov 'display nil)
362-
(overlay-put ov 'face nil))
364+
(overlay-put ov 'face nil)
365+
(treesit-fold-indicators-refresh))
363366

364367
(defun treesit-fold--hide-ov (ov &rest _)
365368
"Hide the OV."
@@ -369,7 +372,8 @@ This function is borrowed from `tree-sitter-node-at-point'."
369372
(overlay-put ov 'display (or (and treesit-fold-summary-show
370373
(treesit-fold-summary--get (buffer-substring beg end)))
371374
treesit-fold-replacement))
372-
(overlay-put ov 'face 'treesit-fold-replacement-face)))
375+
(overlay-put ov 'face 'treesit-fold-replacement-face))
376+
(treesit-fold-indicators-refresh))
373377

374378
(defun treesit-fold-overlay-at (node)
375379
"Return the treesit-fold overlay at NODE if NODE is foldable and folded.

0 commit comments

Comments
 (0)