-
Notifications
You must be signed in to change notification settings - Fork 21
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
List of exported functions and types are inlined despite the default {when_over, 25} setting #88
Comments
I think that this particular issue only presents itself when formatting attributes, like |
I see what's happening here… The formatter online applies [A, B] = Thing …into… [A,
B] = Thing Considering that the exports are a list… they're treated as lists and therefore if the list fits in a single row, it's written in a single row. |
@michalwski I added more info on the README.md in #101… and I think that should be enough, but maybe you or others would like the formatter to actually treat Maybe add another option ( |
@elbrujohalcon thanks for looking into this. It looks like it'd worth to separate the inlining behaviour for |
Cool. Let me grab a list of all the items that are currently affected by
So… @juanbono @diegomanuel @michalwski: How would you split the list? |
@juanbono @diegomanuel @michalwski: Any input here? |
Hi @elbrujohalcon, sorry for the delay. Here's how I'd split the list:
|
@michalwski functions in types are things like… |
@elbrujohalcon I know that. I was just not sure if we need a separate category for that, or maybe it fits some other. The table is only my opinion on the topic. Would be good to know what other people think. |
Oh, right! I understand now. Thanks. |
So, according to your list, @michalwski … we end up with 4 classes of inlining…
Now… I guess, Do you think all others should, by default, not be inlined, even if there are just a few elements? As an example, if is_positive(X) when is_integer(X), X > 0 ->
true. The current formatter will just leave it as it is, but forcing is_positive(X)
when is_integer(X),
X > 0 ->
true. The same goes for -type x() :: dict(integer(), string()). …will become… -type x() :: dict(integer(),
string()). I think -export([f1/0,
f2/0]). …instead of… -export([f1/0, f2/0]). I understand that isolated examples don't show the real problem which is consistency, i.e. either inlining all export blocks or none of them instead of inlining only those that fit in one line and not the others. But I'm still not sure what would be the best solution for this problem… @juanbono / @diegomanuel / @facundoolano / @pbrudnick : opinions? |
Thanks for the examples @elbrujohalcon, this sheds new line on the formatting. I agree that For instance, there could be a dedicated formatting rule for guards. What I have in mind is that they are kept in the same line as long as the line doesn't exceed the limit, only when the line is too long the formatter tries to split it, in a consistent way, for instance, the following too long line: this_is_a_function_with_a_very_long_time(LongVarname, AnotherName) when is_binary(AnotherName), is_list(LongVarname) -> could be formatted like this: this_is_a_function_with_a_very_long_time(LongVarname, AnotherName)
when is_binary(AnotherName), is_list(LongVarname) -> Also when the line starting with The same rule can apply to types, in my opinion. |
Yeah… I agree. I think I'll only implement |
We tried the
default_formatter
in esl/exml#52 with the following settingsand we observed that in most cases the list of exported function and types are in-lined. The expected behaviour is to keep one exported function or type per line.
The text was updated successfully, but these errors were encountered: