[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#67036: 30.0.50; treesit-forward-sexp not working properly in ruby-ts
From: |
Juri Linkov |
Subject: |
bug#67036: 30.0.50; treesit-forward-sexp not working properly in ruby-ts-mode |
Date: |
Mon, 27 Nov 2023 19:06:05 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) |
>>> + # from "elsif" and "then" C-M-f should jump to next "elsif"/"else"
>>> if a == 2 then
>>> puts "hello"
>>> elsif a == 3
>
> Try out the change referenced above, but it doesn't do exactly
> this. Because the tree-sitter parse tree doesn't match the intuition you
> described above.
Thanks for adding "then" and "else" that works not bad.
Then "elsif" could be added as well.
>>> +# when point is after @, C-M-f should jump to the end of symbol
>>> zzz @abc,
>>> 4
>
> This is something that would need to be changed somewhere inside
> treesit-forward-sexp (or treesit--navigate-thing). The default forward-sexp
> behaves differently when in the middle of a symbol.
Agreed, more general changes are needed when point is inside symbols,
strings, comments, etc.
> Also, interactive forward-sexp never reports "No next sexp" when inside
> parens or begin...end. It will do forward-up-list instead.
On the one hand, it's inconsistent with the default non-treesit behavior of
forward-sexp. On the other hand, the default behavior is too annoying
when it screams all the time with "Containing expression ends prematurely!"
instead of doing something useful.
>>> def foo
>>> - self.end
>>> + self.end # when point between 'e' and 'n', C-M-b should jump to "self"
>
> Same as above, although the point will jump to before "end" (after the
> period). And the next C-M-b will jump to before "self".
This looks right.
>>> + class << self
>>> + def bar
>>> + end
>>> + end
>>> + # C-M-b at the end of "end" should jump to "class"
>>> +
>
> Now fixed.
Thanks, confirmed.
>>> 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']
>>> +
>
> As discussed previously, there is no specific node which spans from [ to
> ]. Some custom code could probably be written (there *are* leaf nodes for [
> and ]), but the current capabilities of treesit-thing-settings don't offer
> a good way to plug that in.
Like for point inside strings, this might require more general changes
that take into account syntax tables.