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'm aware that this is not easy because for erlprettypr to apply indentation when needed, the thing that stays in the row above (…( or …{) and the thing that goes to the one below must be considered separate words. That means that if the second one doesn't go below, it will be separated from the other one by a space. In other words, we'll end up with stuff like this…
I've been doing a little bit more digging into prettypr, but to no avail… It looks like those spaces are practically unavoidable.
We might want to do one of these things…
Submit a PR to erlang/otp adding a way to tweak the behaviour of prettypr:hspace/0, prettypr:horizontal/1 and/or prettypr:expand_par/3 to our likings. This is slow.
Fork prettypr just like we forked erl_prettypr and "fix it" to our likings. This is sad.
Do the brutal approach and just remove all spaces after ( and { after formatting the code with prettypr. We need to do it… with extreme care… not to remove spaces from strings, comments, and whatnot. This is difficult and hacky.
Close this issue and leave things as they're now recommending people to just put things in variables or structure your code differently if they don't want to scroll right too much. This is sad.
Yes, the tendency to format code in a narrow column far to the right is a major issue of the algorithm used in prettypr. I don't think it can be avoided. It's one of the reasons I decided against using this algorithm for erlfmt.
Currently,
default_formatter
formats this code……like this…
I would like it to be formatted like this…
I'm aware that this is not easy because for
erlprettypr
to apply indentation when needed, the thing that stays in the row above (…(
or…{
) and the thing that goes to the one below must be considered separate words. That means that if the second one doesn't go below, it will be separated from the other one by a space. In other words, we'll end up with stuff like this……which is undesired. But there might be some sort of alternative solution. We need to do more research.
The text was updated successfully, but these errors were encountered: