diff --git a/packages/language-html/grammars/tree-sitter-html/folds.scm b/packages/language-html/grammars/tree-sitter-html/folds.scm index 5c8919ff7..bc80d5ff6 100644 --- a/packages/language-html/grammars/tree-sitter-html/folds.scm +++ b/packages/language-html/grammars/tree-sitter-html/folds.scm @@ -1,6 +1,74 @@ +; When dealing with a self-closing element that spans multiple lines, this lets +; us fold the attribute list. +; +; This query captures elements that happen to be self-closing but don't end +; with an XHTML-style ` />`. Because `tree-sitter-html` doesn't distinguish +; these from elements that can have content, we have to check the tag name to +; know how to treat these. + +((element + (start_tag + (tag_name) @_IGNORE_) @fold) + (#match? @_IGNORE_ "^(area|base|br|col|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$") +) + +; This one captures the XHTML-style nodes. +(self_closing_tag) @fold + + +; TODO: Right now, the fold cache doesn't work properly when a given range +; satisfies more than one fold. We should employ `ScopeResolver` to fix this. + +; Fold up all of +; +;