diff --git a/src/OmniSharp.Abstractions/Models/v1/TypeLookup/DocumentationComment.cs b/src/OmniSharp.Abstractions/Models/v1/TypeLookup/DocumentationComment.cs index c472ed9652..4dab014516 100644 --- a/src/OmniSharp.Abstractions/Models/v1/TypeLookup/DocumentationComment.cs +++ b/src/OmniSharp.Abstractions/Models/v1/TypeLookup/DocumentationComment.cs @@ -147,7 +147,7 @@ public static DocumentationComment From(string xmlDocumentation, string lineEndi private static string TrimMultiLineString(string input, string lineEnding) { var lines = input.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); - return string.Join(lineEnding, lines.Select(l => l.TrimStart())); + return string.Join(lineEnding, lines.Select(l => TrimStartRetainingSingleLeadingSpace(l))); } private static string GetCref(string cref) @@ -166,6 +166,15 @@ private static string GetCref(string cref) } return cref + " "; } + + private static string TrimStartRetainingSingleLeadingSpace(string input) + { + if (string.IsNullOrWhiteSpace(input)) + return string.Empty; + if (!char.IsWhiteSpace(input[0])) + return input; + return $" {input.TrimStart()}"; + } } class DocumentationItemBuilder diff --git a/tests/OmniSharp.Roslyn.CSharp.Tests/TypeLookupFacts.cs b/tests/OmniSharp.Roslyn.CSharp.Tests/TypeLookupFacts.cs index 4c62f1a14a..cf62e70fb8 100644 --- a/tests/OmniSharp.Roslyn.CSharp.Tests/TypeLookupFacts.cs +++ b/tests/OmniSharp.Roslyn.CSharp.Tests/TypeLookupFacts.cs @@ -452,7 +452,7 @@ public class TestClass }"; var response = await GetTypeLookUpResponse(content); var expected = - @"DoWork is a method in the TestClass class. System.Console.WriteLine(System.String) for information about output statements."; + @"DoWork is a method in the TestClass class. System.Console.WriteLine(System.String) for information about output statements."; Assert.Equal(expected, response.StructuredDocumentation.SummaryText); } @@ -499,7 +499,7 @@ public class TestClass }"; var response = await GetTypeLookUpResponse(content); var expected = - @"This sample shows how to call the TestClass.GetZero method. +@"This sample shows how to call the TestClass.GetZero method. class TestClass { @@ -629,5 +629,22 @@ class testissue @"Returns an array of type T ."; Assert.Equal(expectedReturns, response.StructuredDocumentation.ReturnsText); } + + [Fact] + public async Task StructuredDocumentationSpaceBeforeText() + { + string content = @" +public class TestClass +{ + /// DoWork is a method in the TestClass class. + public static void Do$$Work(int Int1) + { + } +}"; + var response = await GetTypeLookUpResponse(content); + var expected = + @"DoWork is a method in the TestClass class."; + Assert.Equal(expected, response.StructuredDocumentation.SummaryText); + } } }