Subject: bug#62086: 29.0.60; ruby-ts-mode regressions

From: Juri Linkov <[email-masked]>
Date: Tue, 11 Apr 2023 19:53:53 +0300

I don't know if opening a new bug report is needed.
Actually I'm doing the same thing for more ts-modes -
trying to find a set of node names that match parens/brackets.
So maybe this patch makes sense too:

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index d773b4a41f4..e55d26177af 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -927,7 +927,9 @@ c-ts-base-mode
                             "qualifier"
                             "type"
                             "parameter"
-                            "expression"
+                            ;; "expression"
+                            "argument_list"
+                            "identifier"
                             "literal"
                             "string")))
 
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index f68ecb6fa6c..3876a5b54f1 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3827,7 +3827,9 @@ js--treesit-sentence-nodes
 "See `treesit-sentence-type-regexp' for more information.")
 
 (defvar js--treesit-sexp-nodes
-  '("expression"
+  '("expression" ;; SHOULD NOT MATCH "expression_statement", BUT SHOULD MATCH "parenthesized_expression"
+    "parenthesized_expression"
+    "formal_parameters"
     "pattern"
     "array"
     "function"
@@ -3845,7 +3847,13 @@ js--treesit-sexp-nodes
     "undefined"
     "arguments"
     "pair"
-    "jsx")
+    "jsx"
+    "statement_block"
+    "object"
+    "object_pattern"
+    "named_imports"
+    "class_body"
+    )
   "Nodes that designate sexps in JavaScript.
 See `treesit-sexp-type-regexp' for more information.")
 
@@ -3893,7 +3901,7 @@ js-ts-mode
                 (regexp-opt js--treesit-sentence-nodes))
 
     (setq-local treesit-sexp-type-regexp
-                (regexp-opt js--treesit-sexp-nodes))
+                (rx-to-string `(seq bol (or ,@js--treesit-sexp-nodes) eol)))
 
     ;; Fontification.
     (setq-local treesit-font-lock-settings js--treesit-font-lock-settings)