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

Incorect formatting of ternary expresion with a comment after an interpolated string #1258

Closed
mishioo opened this issue May 16, 2024 · 0 comments · Fixed by #1261
Closed
Labels
area:formatting type:bug Something isn't working
Milestone

Comments

@mishioo
Copy link

mishioo commented May 16, 2024

Input:

var x = string.IsNullOrEmpty("")
    ? $"empty" // comment after interpolated string
    : "not empty";

Output:
The second branch of the ternary expression gets moved after the comment on one line.

var x = string.IsNullOrEmpty("") ? $"empty" // comment after interpolated string : "not empty";

Expected behavior:
The expression should be kept separated into multiple lines.
The problem only occurs when the first branch is an interpolated string. For a string with no interpolation, it works as expected and the following is kept as given:

var x = string.IsNullOrEmpty("")
    ? "empty" // without interpolation it's fine
    : "not empty";
@mishioo mishioo changed the title Incorect formatting of ternary expresion a comment after an interpolated string Incorect formatting of ternary expresion with a comment after an interpolated string May 16, 2024
@belav belav added this to the 0.29.0 milestone May 16, 2024
@belav belav added type:bug Something isn't working area:formatting labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:formatting type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants