-
Notifications
You must be signed in to change notification settings - Fork 15
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
Format of andalso
and orelse
#53
Comments
I took a stab at fixing this, and pushed a fix (3b39389) which better respects the max width. New result at 80 chars max width (seems decent): fun main () =
if
1 = 1 andalso 2 = 2 andalso 3 = 3 andalso 4 = 4 andalso 5 = 5 andalso 6 = 6
andalso 7 = 7 andalso 8 = 8
then
print "foo\n"
else
print "bar\n" I'm leaving this open for now though, because it sometimes puts the newline in a "bad place", e.g. here's the output for max 40 chars. fun main () =
if
1 = 1 andalso 2 = 2 andalso 3 = 3
andalso 4 = 4 andalso 5 = 5 andalso 6
= 6
andalso 7 = 7 andalso 8 = 8
then
print "foo\n"
else
print "bar\n" (This is a tricky issue to solve!) |
Thank you for your quick fix, @shwestrick. It seems that after those changes, follow code will be formatted with max width exceeded: fun main () =
let
val foo =
"01234567890123456789012345678901234567890123456789" ^ "01234567890123456789012345678901234567890123456789"
^ "01234567890123456789012345678901234567890123456789"
in
print foo
end |
Thanks, I'll look into it. |
I pushed some updates which fixes this issue by vertically aligning infix expressions. The new output on your example looks like this: fun main () =
let
val foo =
"01234567890123456789012345678901234567890123456789"
^ "01234567890123456789012345678901234567890123456789"
^ "01234567890123456789012345678901234567890123456789"
in
print foo
end I think this is a decent solution for now, and it generally looks pretty good. |
Fix confirmed, nice work! |
It seems that
smlfmt
does not support formating long chain ofandalso
andorelse
, which will exceed the-max-width
limit, e.g.:The text was updated successfully, but these errors were encountered: