Subject: bug#67036: 30.0.50; treesit-forward-sexp not working properly in ruby-ts-mode

From: Juri Linkov <[email-masked]>
Date: Fri, 10 Nov 2023 09:42:17 +0200

X-Debbugs-Cc: [email-masked]

Please try these 5 cases described in the comments of this diff:

diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby.rb b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
index 81d0dfd75c9..abe6a0789b9 100644
--- a/test/lisp/progmodes/ruby-mode-resources/ruby.rb
+++ b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
@@ -123,6 +123,7 @@ def test2 (arg)
     puts "there"
   end
 
+  # from "elsif" and "then" C-M-f should jump to next "elsif"/"else" like with { }
   if a == 2 then
     puts "hello"
   elsif a == 3
@@ -179,6 +180,7 @@ def test2 (arg)
     bar,
     :a
 
+# when point is after @, C-M-f should jump to the end of symbol
 zzz @abc,
     4
 
@@ -211,10 +213,16 @@ def test2 (arg)
 
 class C
   def foo
-    self.end
+    self.end # when point between 'e' and 'n', C-M-b should jump to "self"
     D.new.class
   end
 
+  class << self
+    def bar
+    end
+  end
+  # C-M-b at the end of "end" should jump to "class"
+
   def begin
   end
 end
@@ -522,6 +530,9 @@ def qux
   puts "Japanese translation: #{orig_text} => #{trans_text}"
 end
 
+# C-M-f on '[' doesn't jump to after ']'
+hash['key']
+
 # Tokenizing "**" and "|" separately.
 def resolve(**args)
   members = proc do |**args|

Is it possible to improve ruby-ts-mode to handle these cases?