Formatting Ternary Operator

I see that when I turn on the following option: Code Editing -> C# -> Formatting Style -> Tabs, Indents, Alignment -> Align Multiline Constructs -> Other Expressions, ternary expressions get aligned like so, with a seemingly unnecessary indent:

var foo = bar
? 1
: 2;

Is there anything I can do to get it to align like this instead? Looks a lot better to me.

var foo = bar
? 1
: 2;
1
3 comments

Hello!

 

Thank you for the feedback.

Please try changing ReSharper | Options | Code Editing | C# | Tabs, Indents, Alignment | Continuous line indent multiplier to 0. Will that meet your expectations? 

Thank you.

0
Avatar
Permanently deleted user

Technically, yes, it does make the ternary operator formatted as I'd like, but I don't want to set it to 0 because for other code, I still want to have that tab on that 2nd line. I really don't understand why this option has any effect on ternary operators to be honest. The option to indent "Other expressions" is already indenting with the goal of aligning the ternary operators. The indenting is already being done. Why indent twice, using the "Continuous line indent multiplier" option?

This seems like a bug to me. None of the other "Align Multiline Constructs" are affected by the "Continuous line indent multiplier" option. Why is "Other Expressions"? And on that note, what "other" expressions are there? Why not create an option specific to ternary operators?

0
Avatar
Permanently deleted user

Any update to this? I truly think this is an oversight/bug. Is there a way I can submit it as such?

0

Please sign in to leave a comment.