Skip to content

Commit

Permalink
fix: log message text break at 80 columns (#9464)
Browse files Browse the repository at this point in the history
fix: log message text break at 80 width

Co-authored-by: Yufei Huang <[email protected]>
  • Loading branch information
yufeih and yufeih authored Nov 24, 2023
1 parent d68b9d2 commit fc8404c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Docfx.Common/Loggers/ConsoleLogListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using Docfx.Plugins;
using Spectre.Console;
using Spectre.Console.Rendering;

namespace Docfx.Common;

Expand Down Expand Up @@ -55,7 +56,7 @@ public void WriteLine(ILogItem item)
message.Append(item.Message);

AnsiConsole.Foreground = consoleColor;
AnsiConsole.WriteLine($"{message}");
AnsiConsole.Console.Write(new NonBreakingText($"{message}\n"));
}

public void Dispose()
Expand All @@ -65,4 +66,12 @@ public void Dispose()
public void Flush()
{
}

class NonBreakingText(string text) : IRenderable
{
private readonly Paragraph _paragraph = new(text);

public Measurement Measure(RenderOptions options, int maxWidth) => ((IRenderable)_paragraph).Measure(options, int.MaxValue);
public IEnumerable<Segment> Render(RenderOptions options, int maxWidth) => ((IRenderable)_paragraph).Render(options, int.MaxValue);
}
}

0 comments on commit fc8404c

Please sign in to comment.