From f0a92cf8ab80c93159c939eff2995ccbe24a428a Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 27 Mar 2020 02:24:39 -0700 Subject: [PATCH] restore --- .../Formatting/Indentation/SmartIndenterTests.vb | 2 +- .../Indentation/VisualBasicIndentationService.Indenter.vb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartIndenterTests.vb b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartIndenterTests.vb index cb5451cf82f..8a3d4599186 100644 --- a/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartIndenterTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Formatting/Indentation/SmartIndenterTests.vb @@ -167,7 +167,7 @@ End Module AssertSmartIndent( code, indentationLine:=1, - expectedIndentation:=0) + expectedIndentation:=8) End Sub diff --git a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb index 255c8585149..e4f6cb3be52 100644 --- a/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb +++ b/src/Workspaces/VisualBasic/Portable/Indentation/VisualBasicIndentationService.Indenter.vb @@ -39,6 +39,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Indentation Return New IndentationResult(trivia.SpanStart, 0) End If + ' if the comment is the only thing on a line, then preserve its indentation for the next line. + Dim line = indenter.Text.Lines.GetLineFromPosition(trivia.SpanStart) + If line.GetFirstNonWhitespacePosition() = trivia.SpanStart Then + Return New IndentationResult(trivia.SpanStart, 0) + End If + ' Line ends in comment ' Two cases a line ending comment or _ comment If tokenOpt.HasValue Then -- GitLab