Skip to content

Commit

Permalink
Fix additional spaces getting inserted before element start tags
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Feb 5, 2015
1 parent 6cab57b commit 692a37b
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ private async Task<Document> CreateChangedDocument(CodeFixContext context, Docum
}

if (newContent.Count > 0)
newContent = newContent.Add(XmlSyntaxFactory.NewLine());
newContent = newContent.Add(XmlSyntaxFactory.NewLine().WithTrailingTrivia(SyntaxFactory.DocumentationCommentExterior("///")));

newContent = newContent.Add(XmlSyntaxFactory.Text(line.TrimEnd(), true));
}

contentsOnly = contentsOnly
.WithContent(newContent)
contentsOnly = contentsOnly.WithContent(newContent);
contentsOnly = DocumentValueFromSummaryCodeFix
.ReplaceExteriorTrivia(contentsOnly, leadingTrivia)
.WithLeadingTrivia(SyntaxFactory.DocumentationCommentExterior("///"))
.WithTrailingTrivia(SyntaxFactory.EndOfLine(Environment.NewLine));

Expand All @@ -116,10 +117,6 @@ private async Task<Document> CreateChangedDocument(CodeFixContext context, Docum
if (contentsOnly == null)
return context.Document;

contentsOnly = DocumentValueFromSummaryCodeFix
.ReplaceExteriorTrivia(contentsOnly, leadingTrivia)
.WithLeadingTrivia(SyntaxFactory.DocumentationCommentExterior("///"));

// Remove unnecessary nested paragraph elements
contentsOnly = contentsOnly.ReplaceNodes(contentsOnly.DescendantNodes().OfType<XmlElementSyntax>(), RemoveNestedParagraphs);

Expand Down Expand Up @@ -192,8 +189,9 @@ private SyntaxNode RenderBlockElementAsMarkdown(SyntaxNode originalNode, SyntaxN
return elementSyntax.WithContent(
XmlSyntaxFactory.List(
XmlSyntaxFactory.NewLine().WithoutTrailingTrivia(),
XmlSyntaxFactory.Text(rendered, true),
XmlSyntaxFactory.NewLine().WithoutTrailingTrivia()));
XmlSyntaxFactory.Text(" " + rendered.Replace("\n", "\n "), true),
XmlSyntaxFactory.NewLine().WithoutTrailingTrivia(),
XmlSyntaxFactory.Text(" ")));
}

private string RenderAsMarkdown(string text)
Expand Down

0 comments on commit 692a37b

Please sign in to comment.