Skip to content

Commit

Permalink
Merge pull request #10748 from michalhosala/fix-vbnet-tab-indentation
Browse files Browse the repository at this point in the history
Fixed complex trivia tab indentation
  • Loading branch information
Pilchie committed May 12, 2016
2 parents 27293ac + 7ef2e05 commit c624146
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting

Debug.Assert(Me.SecondTokenIsFirstTokenOnLine OrElse beginningOfNewLine)

If Me.OptionSet.GetOption(FormattingOptions.UseTabs, LanguageNames.VisualBasic) Then
Return True
End If

Return CodeShapeAnalyzer.ShouldFormatMultiLine(context, beginningOfNewLine, list)
End Function

Expand Down
27 changes: 27 additions & 0 deletions src/Workspaces/VisualBasicTest/Formatting/FormattingTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,33 @@ End Class</Code>
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function

<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(10742, "https://github.com/dotnet/roslyn/issues/10742")>
Public Async Function ReFormatWithTabsEnabled6() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Foo() ' Comment" + vbCrLf +
" Foo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"

Dim expected =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Foo() ' Comment" + vbCrLf +
vbTab + vbTab + "Foo()" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"

Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}

Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function

<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsDisabled() As Task
Dim code =
Expand Down

0 comments on commit c624146

Please sign in to comment.