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

Multiple blank lines are allowed after a comment #1443

Closed
maxrzaw opened this issue Jan 17, 2025 · 2 comments · Fixed by #1446
Closed

Multiple blank lines are allowed after a comment #1443

maxrzaw opened this issue Jan 17, 2025 · 2 comments · Fixed by #1446

Comments

@maxrzaw
Copy link

maxrzaw commented Jan 17, 2025

Why does CSharpier remove multiple blank lines in some cases but not others?
In the example below, without the comment, the number of blank lines is reduced to one, but with the comment, I can have as many blank lines as I want. Is this a bug?

If I am understanding #40 correctly, these blank lines should be collapsed into one line.
It wasn't super clear to me if this was part of #66 or #67.

Input:

public class ClassName
{
    public string ShortPropertyName { get; set; }

    public void LongUglyMethod(string longParameter1, string longParameter2, string longParameter3)
    {
        this.LongUglyMethod(
            "1234567890",
            "abcdefghijklmnopqrstuvwxyz",
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        );


        // comment




        var a = "";
    }
}

Output:

public class ClassName
{
    public string ShortPropertyName { get; set; }

    public void LongUglyMethod(string longParameter1, string longParameter2, string longParameter3)
    {
        this.LongUglyMethod(
            "1234567890",
            "abcdefghijklmnopqrstuvwxyz",
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        );

        // comment




        var a = "";
    }
}

Expected behavior:

public class ClassName
{
    public string ShortPropertyName { get; set; }

    public void LongUglyMethod(string longParameter1, string longParameter2, string longParameter3)
    {
        this.LongUglyMethod(
            "1234567890",
            "abcdefghijklmnopqrstuvwxyz",
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        );

        // comment

        var a = "";
    }
}
@maxrzaw
Copy link
Author

maxrzaw commented Jan 17, 2025

It was mentioned that the intention is to follow the same rules for empty lines as prettier and prettier will reduce the number of lines after a comment to 1.

@belav
Copy link
Owner

belav commented Jan 17, 2025

Allowing multiple blank lines after a comment wasn't intentional. I wasn't aware it would leave them when I closed #66.

It turns out condensing them down to a single line is a pretty straightforward. Thanks for reporting the issue!

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 a pull request may close this issue.

2 participants