branch: elpa/treesit-fold
commit eeff646b21961a1470de2cb38560faa9c8d37378
Author: norris <[email protected]>
Commit: GitHub <[email protected]>
Optimize performance of ts-fold-close-all with indicators-mode on (#53)
* Optimize performance of ts-fold-close-all with indicators-mode on
Since ts-fold-close-all and ts-fold-close are both advised,
ts-fold-indicators-refresh will be called every time ts-fold-close-all calls
ts-fold-close on target nodes. Then ts-fold-close-all is far from being
responsive with indicators-mode on.
So we just remove the advice before we call ts-fold-close in
ts-fold-close-all,
and get it back before we leave. Of course, ts-fold-indicators-refresh will
be
called as an advice of ts-fold-close-all which we didn't modify.
* Disable ts-fold-indicators-mode in ts-fold-close-all
Temporarily disable ts-fold-indicators-mode in ts-fold-close-all to avoid
ts-fold-indicators-refresh for each ts-fold-close call in
ts-fold-close-all. So it is unnecessary to modify the advice.
---------
Co-authored-by: Arto Young <[email protected]>
---
ts-fold.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ts-fold.el b/ts-fold.el
index ed060af687..e6c20cb347 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -324,7 +324,8 @@ If the current node is not folded or not foldable, do
nothing."
"Fold all foldable syntax nodes in the buffer."
(interactive)
(ts-fold--ensure-ts
- (let* ((node (tsc-root-node tree-sitter-tree))
+ (let* ((ts-fold-indicators-mode)
+ (node (tsc-root-node tree-sitter-tree))
(patterns (seq-mapcat (lambda (fold-range) `((,(car fold-range))
@name))
(alist-get major-mode ts-fold-range-alist)
'vector))