Skip to content

Commit

Permalink
Merge pull request #1064 from akshita31/space_after_c
Browse files Browse the repository at this point in the history
Retain single leading space when appending string in TypeLookUp
  • Loading branch information
david-driscoll authored Jan 9, 2018
2 parents f0a3ac1 + 0f5d3dd commit 55eadc0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
21 changes: 19 additions & 2 deletions tests/OmniSharp.Roslyn.CSharp.Tests/TypeLookupFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
/// <summary><c>DoWork</c> is a method in the <c>TestClass</c> class.</summary>
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);
}
}
}

0 comments on commit 55eadc0

Please sign in to comment.