-
Notifications
You must be signed in to change notification settings - Fork 38
[Printer] - Multiline string as first function argument breaks formatting #212
Comments
Yes, this is occurring in our codebase a lot and the current form without indentation is quite ugly. See #35. |
@eWert-Online Thanks for the report, this is indeed a bug. Will look into this. @jfrolich If you see other weird patterns in your codebase, feel free to report them. Will probably have a look at "indented strings" end of Q1 2021. |
@IwanKaramazow: Great! This was also an issue with Reason, so not really a regression, but I feel like it's something that exists in almost any modern programming language so it would be good to have it for ergonomics. |
Fix #212 Sometimes one of the non-callback arguments will break in a function application where the first or last argument is a callback. There might be a single line comment in there, or a multiline string. We want to break all the arguments in this case for readability. **before** ```rescript showDialog( ` Do you really want to leave this workspace? Some more text with detailed explanations... `, danger=true, ~confirmText="Yes, I am sure!", ~onConfirm={() => ()}, ) ``` **after** ```rescript showDialog( ` Do you really want to leave this workspace? Some more text with detailed explanations... `, ~danger=true, ~confirmText="Yes, I am sure!", ~onConfirm={() => ()}, ) ```
Fix #212 Sometimes one of the non-callback arguments will break in a function application where the first or last argument is a callback. There might be a single line comment in there, or a multiline string. We want to break all the arguments in this case for readability. **before** ```rescript showDialog( ` Do you really want to leave this workspace? Some more text with detailed explanations... `, danger=true, ~confirmText="Yes, I am sure!", ~onConfirm={() => ()}, ) ``` **after** ```rescript showDialog( ` Do you really want to leave this workspace? Some more text with detailed explanations... `, ~danger=true, ~confirmText="Yes, I am sure!", ~onConfirm={() => ()}, ) ```
…ks (#241) Fix #212 Sometimes one of the non-callback arguments will break in a function application where the first or last argument is a callback. There might be a single line comment in there, or a multiline string. We want to break all the arguments in this case for readability. **before** ```rescript showDialog( ` Do you really want to leave this workspace? Some more text with detailed explanations... `, danger=true, ~confirmText="Yes, I am sure!", ~onConfirm={() => ()}, ) ``` **after** ```rescript showDialog( ` Do you really want to leave this workspace? Some more text with detailed explanations... `, ~danger=true, ~confirmText="Yes, I am sure!", ~onConfirm={() => ()}, ) ```
@eWert-Online Sorry for the delay, but this is now fixed in master. Thank you so much for the report. This was a complex edge case. @jfrolich I haven't forgotten about "indented multiline strings", will tackle this at at later time. Jsx4 and custom operators are getting my full attention. |
@IwanKaramazow: You're doing an amazing job with the syntax @IwanKaramazow, love the progress! 🙌 |
…ks (rescript-lang#241) Fix rescript-lang/syntax#212 Sometimes one of the non-callback arguments will break in a function application where the first or last argument is a callback. There might be a single line comment in there, or a multiline string. We want to break all the arguments in this case for readability. **before** ```rescript showDialog( ` Do you really want to leave this workspace? Some more text with detailed explanations... `, danger=true, ~confirmText="Yes, I am sure!", ~onConfirm={() => ()}, ) ``` **after** ```rescript showDialog( ` Do you really want to leave this workspace? Some more text with detailed explanations... `, ~danger=true, ~confirmText="Yes, I am sure!", ~onConfirm={() => ()}, ) ```
The following function call stays as it is, which is, what I expect.
As soon as I break the multiline string into multiple lines, for example like this:
It gets printed like this:
I would expect it to stay like the second example.
(When I move the multiline string to the last position, it gets printed as I would expect.)
Playground example
The text was updated successfully, but these errors were encountered: