Skip to content

Commit

Permalink
🐛 Fix inconsistency in paragraph newline render on non-Win
Browse files Browse the repository at this point in the history
Consider the platform when checking for previously added newlines in the buffer.

Fixes devlooped#25
  • Loading branch information
kzu committed Jan 28, 2021
1 parent 2e4f37a commit 20faa20
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/NuDoq.Tests/ToTextFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void when_rendering_see_then_renders_cref()
}

[Fact]
public void when_rendering_paragram_then_renders_wrapping_new_lines()
public void when_rendering_paragraph_then_renders_wrapping_new_lines()
{
var map = new MemberIdMap();
map.Add(typeof(ProviderType));
Expand Down
10 changes: 8 additions & 2 deletions src/NuDoq/TextVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ public override void VisitSee(See see)
public override void VisitPara(Para para)
{
// Avoid double line breaks between adjacent <para> elements.
if (builder.Length < 2 ||
new string(new char[] { builder[builder.Length - 2], builder[builder.Length - 1] }) != Environment.NewLine)
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
if (builder.Length < 2 ||
new string(new char[] { builder[builder.Length - 2], builder[builder.Length - 1] }) != Environment.NewLine)
builder.AppendLine();
}
else if (builder.Length < 1 ||
builder[builder.Length - 1].ToString() != Environment.NewLine)
{
builder.AppendLine();
}
Expand Down

0 comments on commit 20faa20

Please sign in to comment.