Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

* Building AppHost...
playground\HealthChecks\HealthChecksSa
ndbox.AppHost\AppHost.csproj

* Building AppHost...
playground\HealthChecks\HealthChecksSa
ndbox.AppHost\AppHost.csproj

Original file line number Diff line number Diff line change
Expand Up @@ -3138,6 +3138,7 @@
public TaskDescriptionColumn() { }
public Spectre.Console.Justify Alignment { get; set; }
protected override bool NoWrap { get; }
public bool Wrap { get; set; }
public override Spectre.Console.Rendering.IRenderable Render(Spectre.Console.Rendering.RenderOptions options, Spectre.Console.ProgressTask task, System.TimeSpan deltaTime) { }
}
[System.Diagnostics.DebuggerDisplay("{_text,nq}")]
Expand Down
25 changes: 25 additions & 0 deletions src/Spectre.Console.Tests/Unit/Live/StatusTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,29 @@ public Task Should_Render_Status_Correctly()
// Then
return Verifier.Verify(console.Output);
}

[Fact]
[Expectation("Render_LongText")]
[GitHubIssue("https://github.com/spectreconsole/spectre.console/issues/2152")]
public Task Should_Wrap_Status_Text_That_Exceeds_The_Console_Width()
{
// Given
var console = new TestConsole()
.Width(40)
.Interactive();

var status = new Status(console)
{
AutoRefresh = false,
Spinner = new DummySpinner1(),
};

// When
status.Start(
"Building AppHost... playground\\HealthChecks\\HealthChecksSandbox.AppHost\\AppHost.csproj",
ctx => ctx.Refresh());

// Then
return Verifier.Verify(console.Output);
}
}
13 changes: 11 additions & 2 deletions src/Spectre.Console/Live/Progress/Columns/TaskDescriptionColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ namespace Spectre.Console;
public sealed class TaskDescriptionColumn : ProgressColumn
{
/// <inheritdoc/>
protected internal override bool NoWrap => true;
protected internal override bool NoWrap => !Wrap;

/// <summary>
/// Gets or sets a value indicating whether the description should wrap
/// onto multiple lines when it's wider than the available space.
/// Defaults to <c>false</c>, which truncates the description with an ellipsis.
/// </summary>
public bool Wrap { get; set; }

/// <summary>
/// Gets or sets the alignment of the task description.
Expand All @@ -17,6 +24,8 @@ public sealed class TaskDescriptionColumn : ProgressColumn
public override IRenderable Render(RenderOptions options, ProgressTask task, TimeSpan deltaTime)
{
var text = task.Description?.RemoveNewLines()?.Trim();
return new Markup(text ?? string.Empty).Overflow(Overflow.Ellipsis).Justify(Alignment);
return new Markup(text ?? string.Empty)
.Overflow(Wrap ? Overflow.Fold : Overflow.Ellipsis)
.Justify(Alignment);
}
}
6 changes: 5 additions & 1 deletion src/Spectre.Console/Live/Status/Status.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ public async Task<T> StartAsync<T>(string status, Func<StatusContext, Task<T>> f
progress.Columns(new ProgressColumn[]
{
spinnerColumn,
new TaskDescriptionColumn(),
new TaskDescriptionColumn
{
Wrap = true,
Alignment = Justify.Left,
},
});

return await progress.StartAsync(async ctx =>
Expand Down