Skip to content
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

Merged
merged 1 commit into from
Jun 14, 2021
Merged

Formatting with csharpier 0.9.6 #305

merged 1 commit into from
Jun 14, 2021

Conversation

belav
Copy link
Owner

@belav belav commented Jun 14, 2021

No description provided.

@belav belav merged commit 7ed2638 into master Jun 14, 2021
@belav belav deleted the format-with-0.9.6 branch June 14, 2021 16:23
@@ -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(
Copy link
Collaborator

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?

Copy link
Owner Author

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
    );

Copy link
Collaborator

@shocklateboy92 shocklateboy92 Jun 17, 2021

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?

Copy link
Owner Author

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,
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants