-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Formatting with csharpier 0.9.6 #305
Conversation
@@ -31,8 +31,11 @@ protected void RunTest(string folderName, string fileName, bool useTabs = false) | |||
folderName, | |||
fileName + ".cst" | |||
); | |||
var fileReaderResult = | |||
FileReader.ReadFile(filePath, new FileSystem(), CancellationToken.None).Result; | |||
var fileReaderResult = FileReader.ReadFile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this what we're going with for everything now?
I think we should try breaking on the assignment group before breaking the right hand side, don't you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be just temporary. The idea is that with a conditional group we can say
//format this way if it fits (this would use a Line after = to keep it on a single line when possible)
var someObject =
CallSomeMethod(withSomeParameters, likeSo);
// and if that doesn't fit, then try
var someObject = CallSomeMethod(
withSomeParameters,
likeSo
);
Without conditional groups when it gets too long it would end up as
var someObject =
CallSomeMethod(
withSomeParameters,
likeSo
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be perfectly honest, I don't think the 3rd case looks too bad. But I also don't feel strongly enough to push for it either.
Instead of a conditional group, can you use a BreakParent()
combined with an IfBreak()
to achieve the second case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a conditional group, can you use a BreakParent() combined with an IfBreak() to achieve the second case?
It might be possible. In my head it seems like it could work.
I know prettier uses conditional groups for this type of formatting, so I've been assuming we are going to need them as well. It is definitely worth trying out alternatives before using conditional groups. I believe they add a lot of extra computation to the printing process when they are used.
public static readonly HardLine HardLineIfNoPreviousLineSkipBreakIfFirstInGroup = | ||
new(true, true); | ||
public static readonly HardLine HardLineIfNoPreviousLineSkipBreakIfFirstInGroup = new( | ||
true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Especially for something like this, the old break looked much better IMHO
No description provided.