You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to add my proposal about this. Pattern matching formatting right now is kind-of ugly, and hard to read if you ask me. So imho this issue is bigger than this single case.
I'm not sure if this is recognized as an area of improvement and/or if there's an umbrella issue for this, but there could be many formatting possibilities when it comes to pattern matching.
Also a lot depends on proposals that might shorten the current's pattern matching syntax.
I just want to underline that the following proposal is naive and probably might need to improve.
I'd propose to format the above as:
if (
node.parent caseMethodInvocation(:var target)
when target == whatever
)
Which consumes more white space, but at least the pattern match is crystal clear. IMHO you can easily read where the if statement begins, where it ends, which variables are matched and against who. The when clause has the same magnitude as the case clause.
AFAIK a little more white space should harmless, so... let me show another example.
A more complex case could be the following (formatted "as of now"):
Again, I'm not sure people would like this. My goal with this comment is to ask you guys if this has been ever thought over / what's the current state of proposal about this problem, and if this is even recognized as a problem. It might be a starting point.
If you have a code like:
Today it formats like this:
In this case I think it should prefer to add a new line before
when
rather than making a whole new line for:var target
.The text was updated successfully, but these errors were encountered: