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 of list-patterns on multiple lines is incorrect #57244

Closed
jcouv opened this issue Oct 19, 2021 · 6 comments · Fixed by #57568
Closed

Formatting of list-patterns on multiple lines is incorrect #57244

jcouv opened this issue Oct 19, 2021 · 6 comments · Fixed by #57568

Comments

@jcouv
Copy link
Member

jcouv commented Oct 19, 2021

This issue is referenced in tests from PR #53850

Relates to test plan #51289

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Oct 19, 2021
@jinujoseph jinujoseph added Concept-Continuous Improvement and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 20, 2021
@jinujoseph jinujoseph added this to the 17.1.P1 milestone Oct 20, 2021
@jcouv
Copy link
Member Author

jcouv commented Oct 20, 2021

@jinujoseph I'm afraid this issue needs attention from someone with a bit more expertise. I tried to fix this today but was unable to.

@sharwell
Copy link
Member

@jcouv I looked at the linked PR and wasn't able to figure out what the request here is.

@sharwell sharwell added the IDE-Formatter Code formatter and/or smart indent label Oct 21, 2021
@jcouv
Copy link
Member Author

jcouv commented Oct 21, 2021

@sharwell My PR fixed formatting of list-patterns on a single line (which is the common case). But when it comes to multi-line format, it's probably not right (it's not doing anything).
Specifically:

  1. if you type x is [ <enter>, we probably want the open brace to be pushed to the next line and the cursor to be place with a deeper indentation like this:
_ = x is
[
    $$
]
  1. if you start from a non-formatted multi-line sample like the following, we don't know how to properly format it:
    _ = x is
        [
1,
    2,
 ];

It probably should be something like one of these two (not sure which):

    _ = x is
    [
        1,
        2,
    ];

or maybe

    _ = x is
        [
            1,
            2,
        ];

Note: the existing scenario with braces is array instantiation. We also don't know how to format those on multiple lines (I guess it's very uncommon as well).

@davidwengier
Copy link
Contributor

@jinujoseph I'm afraid this issue needs attention from someone with a bit more expertise. I tried to fix this today but was unable to.

Good news, its been assigned to me.

Bad news, I've literally never touched or seen the C# formatter code 😛

@jcouv
Copy link
Member Author

jcouv commented Oct 22, 2021

Thanks @davidwengier
If that helps, I've been collecting notes from my previous forays. We can build on that and make it easier for next time.
https://github.com/dotnet/roslyn/blob/main/docs/wiki/Notes-on-formatting.md

@jinujoseph jinujoseph modified the milestones: 17.1.P2, 17.1 Jan 12, 2022
@jcouv jcouv modified the milestones: 17.1, 17.2 Feb 4, 2022
@jcouv
Copy link
Member Author

jcouv commented Feb 18, 2022

Thanks @davidwengier for fixing this!

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

Successfully merging a pull request may close this issue.

4 participants