-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Adjust indent block operations used for VB smart indent in argument lists #25344
Changes from 2 commits
4fa524b
7b9fb74
bf9aeb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2802,6 +2802,79 @@ End Class | |
|
||
<WorkItem(3293, "https://github.com/dotnet/roslyn/issues/3293")> | ||
<WpfFact, Trait(Traits.Feature, Traits.Features.SmartIndent)> | ||
Public Sub TestSmartIndentInArgumentLists1() | ||
Dim code = " | ||
Class C | ||
Sub M() | ||
Console.WriteLine(""{0} + {1}"", | ||
|
||
End Sub | ||
End Class" | ||
|
||
AssertSmartIndent( | ||
code, | ||
indentationLine:=4, | ||
expectedIndentation:=26) | ||
End Sub | ||
|
||
<WorkItem(3293, "https://github.com/dotnet/roslyn/issues/3293")> | ||
<WpfFact, Trait(Traits.Feature, Traits.Features.SmartIndent)> | ||
Public Sub TestSmartIndentInArgumentLists2() | ||
Dim code = " | ||
Class C | ||
Sub M() | ||
Console.WriteLine(""{0} + {1}"", | ||
19, | ||
|
||
End Sub | ||
End Class" | ||
|
||
AssertSmartIndent( | ||
code, | ||
indentationLine:=5, | ||
expectedIndentation:=12) | ||
End Sub | ||
|
||
<WorkItem(3293, "https://github.com/dotnet/roslyn/issues/3293")> | ||
<WpfFact, Trait(Traits.Feature, Traits.Features.SmartIndent)> | ||
Public Sub TestSmartIndentInArgumentLists3() | ||
Dim code = " | ||
Class C | ||
Sub M() | ||
Console.WriteLine(""{0} + {1}"", | ||
19, 23 + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 This test doesn't cover the case I was describing because
📝 My case isn't as contrives as you'd think. Consider the following: Method(
CallArgument1(
x,
y,
z
), Argument2, ' <-- Press enter here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I missed the first There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No problem, the additional ones you did add were good tests too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And FWIW, I would expect that it would indent to the second argument in this case. I don't think that's necessarily correct, but it's a pretty fishy scenario. |
||
19, | ||
|
||
End Sub | ||
End Class" | ||
|
||
AssertSmartIndent( | ||
code, | ||
indentationLine:=6, | ||
expectedIndentation:=12) | ||
End Sub | ||
|
||
<WorkItem(3293, "https://github.com/dotnet/roslyn/issues/3293")> | ||
<WpfFact, Trait(Traits.Feature, Traits.Features.SmartIndent)> | ||
Public Sub TestSmartIndentInArgumentLists4() | ||
Dim code = " | ||
Class C | ||
Sub M() | ||
Console.WriteLine(""{0} + {1}"", | ||
19, 23, | ||
19, | ||
|
||
End Sub | ||
End Class" | ||
|
||
AssertSmartIndent( | ||
code, | ||
indentationLine:=6, | ||
expectedIndentation:=16) | ||
End Sub | ||
|
||
<WorkItem(25323, "https://github.com/dotnet/roslyn/issues/25323")> | ||
<WpfFact, Trait(Traits.Feature, Traits.Features.SmartIndent)> | ||
Public Sub TestSmartIndentAtCaseBlockEndUntabbedComment() | ||
Dim code = <code>Class Program | ||
Public Sub M() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ What happens if the argument is split across lines, but doesn't actually start a line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine to be better on smart indent on expression. but just as FYI.
both C# and VB never tries to be too smart on multi line expressions. every one has different liking on those on every different cases even for same construct. (that's why formatter never force formatting on expressions)
we do have some special cases like argument or parameter lists, but even for those, we did very simple thing. (so that it can be predictable)
most of time, if expression is more than 2 lines a part, we just give up and act like simple block indent (either align with previous line or 4 space added after previous line)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one thing I hope we don't do is, we forcing people to follow our liking and make them to demand options for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Good question. I'll add a test or two to cover this scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heejaechang: We aren't forcing people to follow our liking with this change and no options would ever be required. Instead, we're treating the special case of argument lists (which is different between C# and VB) to be a bit more natural. IOW, this should better match the user's expectations.