-
-
Notifications
You must be signed in to change notification settings - Fork 58
Transform between braces & do/end when reflowing blocks? #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
So it's doing that because it's trying to be careful. Normally it would happily convert to a Here's an example of what I mean: expect foo, bar { baz } That works fine, but if expect foo, bar do
bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
end this actually changes the meaning to the block being given to the syntax_tree/lib/syntax_tree/node.rb Lines 1974 to 1985 in 3f5b736
To fix this, as it's walking up the tree is should notice that it's inside of a method call with parentheses (like it notices it's inside a statement list) and stop walking up the tree. That would fix this. Feel like giving this one a shot? |
I'll give it a try; thanks for the advice. |
I was rather surprised to see Syntax Tree make the following choice:
It was preserving my choice of
{}
but when it reflowed the block to multiple lines, our convention normally would have been to switch to ado/end
pair (and vice-versa).As a workaround, I can Rubocop to auto-fix after formatting; it's a minor pain however. Is this a behavior that would be amenable to a Syntax Tree plugin? If so, perhaps I can work on contributing one to the core.
The text was updated successfully, but these errors were encountered: