Replies: 1 comment 3 replies
-
Your examples have the syntax tree organized so that method calls are right-associative rather than left but method calls in Rust are left-associative. tree-sitter-rust is correct in this case: if you rewrote the expression with explicit parentheses, it would be: let r = (((test(1, 2).saturating_add(3)).saturating_sub(4)); |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Suppose we have this:
(|...| delimits the selection)
let r = test(0, 2).saturating_|a|dd(3).saturating_sub(4);
This is what TS "expand selection to parent syntax node" currently does:
let r = test(1, 2).|saturating_add|(3).saturating_sub(4);
let r = |test(1, 2).saturating_add|(3).saturating_sub(4);
let r = |test(1, 2).saturating_add(3)|.saturating_sub(4);
let r = |test(1, 2).saturating_add(3).saturating_sub|(4);
let r = |test(1, 2).saturating_add(3).saturating_sub(4)|;
That's not very useful.
This is what I would expect:
let r = test(1, 2).|saturating_add|(3).saturating_sub(4);
let r = test(1, 2).|saturating_add(3)|.saturating_sub(4);
let r = test(1, 2).|saturating_add(3).saturating_sub|(4);
let r = test(1, 2).|saturating_add(3).saturating_sub(4)|;
let r = test|(1, 2).saturating_add(3).saturating_sub(4)|;
// Or
let r = test(1, 2).|saturating_add|(3).saturating_sub(4);
let r = test(1, 2).|saturating_add(3)|.saturating_sub(4);
let r = test(1, 2).|saturating_add(3).saturating_sub(4)|;
let r = |test(1, 2).saturating_add(3).saturating_sub(4)|;
You get the idea.
This is only the first example that comes to my mind, there are other similar
situations where TS expand goes the "wrong way", at least in Rust.
Would be possible to make the expand selection more smarter?
Beta Was this translation helpful? Give feedback.
All reactions