Fix formatting irregularities with spaces

This commit is contained in:
Matt Nadareski
2025-10-05 13:05:38 -04:00
parent 0553deda4d
commit 681cd93f69
2 changed files with 10 additions and 2 deletions

View File

@@ -109,6 +109,7 @@ namespace SabreTools.CommandLine.Test
[InlineData("Some long description\nwith a newline", 3)]
[InlineData("Some long description\nwith\nmultiple\nnewlines", 5)]
[InlineData("Some long description\n - With formatting", 3)]
[InlineData("Some long description with multiple spaces", 2)]
public void FormatLongDescriptionTest(string longDescription, int expectedCount)
{
var feature = new MockFeature("a", "a", "a", longDescription);

View File

@@ -710,7 +710,7 @@ namespace SabreTools.CommandLine.Inputs
// Normalize the description for output
string longDescription = _longDescription!.Replace("\r\n", "\n");
longDescription = longDescription.Replace("\n", "\n" + CreatePadding(pre + 4));
longDescription = longDescription.Replace("\n", "\n ");
// Get the width of the console for wrapping reference
int width = (Console.WindowWidth == 0 ? 80 : Console.WindowWidth) - 1;
@@ -727,7 +727,14 @@ namespace SabreTools.CommandLine.Inputs
// Cache the current segment
string segment = split[i];
// If we have a newline character, reset the line and continue
// If the segment is empty
if (segment.Length == 0)
{
output.Append(" ");
continue;
}
// If the line ends with a newline
bool forceSplit = false;
if (segment.EndsWith("\n"))
{