From ef26c588a302c09abaa3a7a61612417926f0f2db Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Thu, 13 Jun 2024 14:09:23 -0700 Subject: [PATCH] =?UTF-8?q?[language-ruby]=20Fix=20our=20attempt=20to=20fo?= =?UTF-8?q?ld=20Ruby=20comments=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …so that it doesn’t try to look up a child node that we know won’t exist. Most Ruby comments aren’t foldable because they start and end on the same line — by their very nature! But there is one obscure multi-line syntax that we can support, so this tells Pulsar to fold to the end of the comment itself. --- packages/language-ruby/grammars/tree-sitter-ruby/folds.scm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/language-ruby/grammars/tree-sitter-ruby/folds.scm b/packages/language-ruby/grammars/tree-sitter-ruby/folds.scm index a78947bee..753cea4f1 100644 --- a/packages/language-ruby/grammars/tree-sitter-ruby/folds.scm +++ b/packages/language-ruby/grammars/tree-sitter-ruby/folds.scm @@ -1,6 +1,5 @@ [ (method) - (comment) (singleton_method) (class) (module) @@ -16,6 +15,10 @@ (string_array) ] @fold +; Multi-line comment syntax (=begin…=end) is obscure and out of favor, but we +; might as well make it foldable. +((comment) @fold + (#set! fold.endAt endPosition)) ; Fold from `if` to the next `elsif` or `else` in the chain. ((if