bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#62416: 30.0.50; Symbols skipped in the navigation in ruby-ts-mode


From: Dmitry Gutov
Subject: bug#62416: 30.0.50; Symbols skipped in the navigation in ruby-ts-mode
Date: Wed, 29 Mar 2023 01:24:49 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0

On 28/03/2023 09:31, Juri Linkov wrote:
This will break other cases, e.g.
    b = %Q{This is a "string"}
    c = %w!foo
     bar
     baz!
    d = %(hello (nested) world)
when point is after "b", 'C-M-f' will move to "c" instead of the end of
line.

That is because the string literals aren't recognized as sexps yet. Try
this:

@@ -1129,8 +1129,11 @@ ruby-ts-mode
                              "block"
                              "do_block"
                              "begin"
-                            "binary"
-                            "assignment")))
+                            "integer"
+                            "simple_symbol"
+                            "string"
+                            "string_array"
+                            )))

Thanks, this definitely is an improvement since it handles all mentioned cases.

Very good, I've pushed that change, and with that I'm closing this bug. Thank you both.

However, there are still a lot of more things that need fixing.
When point is on the left curly bracket in

   b = %Q{This is a "string"}

'C-M-f' doesn't move to the right curly bracket.
Also double quotes inside the string are not matched by 'C-M-f'.

In

   d = %(hello (nested) world)

'C-M-f' doesn't move to the closing parens from opening parens.

Looking at test/lisp/progmodes/ruby-mode-resources/ruby.rb
for example here curly brackets are not matched with 'C-M-f C-M-b'
in string interpolation and regexps:

   "abc/#{ddf}ghi"

   /foo/xi != %r{bar}mo.tee

Do you think it is possible to handle these cases
by crafting treesit-sexp-type-regexp?

I don't think so. tree-sitter parse tree has no information about these parens or their positions.

So we'd need to do this with some custom code: check the context (e.g. see that we are inside a string) and then move over parens and etc. It's not out of the question to do that in the common tree-sitter code, too (Ruby doesn't look very special in having strings). But whether this is useful enough to expend that effort, seems like a subject for a separate discussion (report-emacs-bug or emacs-devel -- your choice).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]