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

Spread (in collection expression) are not formatted #1167

Closed
jods4 opened this issue Feb 8, 2024 · 0 comments · Fixed by #1179
Closed

Spread (in collection expression) are not formatted #1167

jods4 opened this issue Feb 8, 2024 · 0 comments · Fixed by #1179
Milestone

Comments

@jods4
Copy link

jods4 commented Feb 8, 2024

Input:

List<KeyValuePair<string, string>> list =
[..    attribute.Targets.Select(target =>    KeyValuePair.Create(target, context.EntityDefinitions.TryGetValue(target, out var type) ? type.ClassName : null)).Where(kvp => kvp.Value != null)];

Output:

List<KeyValuePair<string, string>> list =
[
    ..    attribute.Targets.Select(target =>    KeyValuePair.Create(target, context.EntityDefinitions.TryGetValue(target, out var type) ? type.ClassName : null)).Where(kvp => kvp.Value != null)
];

Expected behavior:
The spread doesn't seem to be formatted at all.
For example, extra spaces after the .. or after => are not condensed.
The line is extremely long but it's not broken.

I would expect something like

List<KeyValuePair<string, string>> list =
[
    ..attribute
        .Targets.Select(target =>
            KeyValuePair.Create(
                target,
                context.EntityDefinitions.TryGetValue(target, out var type) ? type.ClassName : null
            )
        )
        .Where(kvp => kvp.Value != null)
];
@belav belav added this to the 0.27.3 milestone Feb 11, 2024
belav added a commit that referenced this issue Feb 17, 2024
belav added a commit that referenced this issue Feb 18, 2024
* Adding formatting for spread element

closes #1167

* add spread walker
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