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
printWidth should only limit the maximum length of a line.
If the line exceeds this maximum length, it should automatically break.
However, if the line does not exceed the maximum length, it should not forcefully merge already broken code into a single line.
CSharpier does not take into account any existing line breaks when deciding how to format code.
Prettier for the most part functions the exact same way although it does have a couple (possibly controversial) cases where it will format differently based on if the current statement is already broken or not. They have reasons for it being included even though they'd preferred to have avoided it - https://prettier.io/docs/rationale#multi-line-objects
For this specific instance CSharpier may break invocation chains that meet a certain criteria even if they are not longer than the max width, see #792. I don't see CSharpier changing to take into account existing line breaks when dealing with invocations however.
Input:
For example, given the following code:
Output:
I have not configured printWidth (the default value is 100). When I save the code and trigger code formatting, it changes to:
Expected behavior:
Only when I modify printWidth to a smaller value, such as 50, does it produce the desired effect.
Is there any way to prevent this behavior?
My Suggestion:
printWidth
should only limit the maximum length of a line.If the line exceeds this maximum length, it should automatically break.
However, if the line does not exceed the maximum length, it should not forcefully merge already broken code into a single line.
I use the CSharpier plugin in Visual Studio for code formatting.
CSharpier - Visual Studio Marketplace
version: 2.0.1
The text was updated successfully, but these errors were encountered: