From ba336a9d272239ca2061bf64f45cc77bac5927e0 Mon Sep 17 00:00:00 2001 From: DinoChiesa Date: Tue, 8 Jul 2025 18:18:22 -0700 Subject: [PATCH] fix: folding html element will include attributes and close element For html-mode and html-ts-mode, without this change, treesit-fold folds from the END (closing angle bracket) of the opening element to the beginning (opening angle bracket) of the close element. That means attributes on the element are not included in the fold. Modern HTML can include lots of attributes. Folding from the END of the opening element name to the END (closing angle bracket) of the closing element, will include attributes in the fold. This change does that. --- treesit-fold.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/treesit-fold.el b/treesit-fold.el index 79358fb..e4e2ba3 100644 --- a/treesit-fold.el +++ b/treesit-fold.el @@ -977,8 +977,10 @@ more information." For arguments NODE and OFFSET, see function `treesit-fold-range-seq' for more information." - (let* ((beg (treesit-node-end (treesit-node-child node 0))) - (end-node (treesit-fold-last-child node)) + (let* (;; beg = after element name that follows open angle bracket + (beg (treesit-node-end (treesit-node-child (treesit-node-child node 0) 1))) + ;; end-node is the closing angle bracket + (end-node (treesit-node-child (treesit-fold-last-child node) 2)) (end (treesit-node-start end-node))) (treesit-fold--cons-add (cons beg end) offset)))