diff --git a/src/Spectre.Console/Live/LiveRenderable.cs b/src/Spectre.Console/Live/LiveRenderable.cs index 40107f9cd..a681d2405 100644 --- a/src/Spectre.Console/Live/LiveRenderable.cs +++ b/src/Spectre.Console/Live/LiveRenderable.cs @@ -49,7 +49,7 @@ public IRenderable PositionCursor() } var linesToMoveUp = _shape.Value.Height - 1; - return new ControlCode("\r" + CUU(linesToMoveUp)); + return new ControlCode("\r" + (EL(2) + CUU(1)).Repeat(linesToMoveUp)); } } diff --git a/test/Spectre.Console.Tests/Expectations/Live/Status/Render.Output.verified.txt b/test/Spectre.Console.Tests/Expectations/Live/Status/Render.Output.verified.txt index debe2399d..cd5fed942 100644 --- a/test/Spectre.Console.Tests/Expectations/Live/Status/Render.Output.verified.txt +++ b/test/Spectre.Console.Tests/Expectations/Live/Status/Render.Output.verified.txt @@ -1,10 +1,10 @@ [?25l * foo - + - bar - + * baz [?25h \ No newline at end of file diff --git a/test/Spectre.Console.Tests/Expectations/Live/Status/WriteLineOverflow.Output.verified.txt b/test/Spectre.Console.Tests/Expectations/Live/Status/WriteLineOverflow.Output.verified.txt new file mode 100644 index 000000000..d3647bb50 --- /dev/null +++ b/test/Spectre.Console.Tests/Expectations/Live/Status/WriteLineOverflow.Output.verified.txt @@ -0,0 +1,12 @@ +[?25l +⣷ long text that should not interfere writeline text + +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxx + +⣷ long text that should not interfere writeline text + + +⣷ long text that should not interfere writeline text + +[?25h \ No newline at end of file diff --git a/test/Spectre.Console.Tests/Unit/Live/StatusTests.cs b/test/Spectre.Console.Tests/Unit/Live/StatusTests.cs index 60f914d56..dc4723dfe 100644 --- a/test/Spectre.Console.Tests/Unit/Live/StatusTests.cs +++ b/test/Spectre.Console.Tests/Unit/Live/StatusTests.cs @@ -49,4 +49,30 @@ public Task Should_Render_Status_Correctly() // Then return Verifier.Verify(console.Output); } + + [Fact] + [Expectation("WriteLineOverflow")] + public Task Should_Render_Correctly_When_WriteLine_Exceeds_Console_Width() + { + // Given + var console = new TestConsole() + .Colors(ColorSystem.TrueColor) + .Width(100) + .Interactive() + .EmitAnsiSequences(); + var status = new Status(console) + { + AutoRefresh = false, + }; + + // When + status.Start("long text that should not interfere writeline text", ctx => + { + ctx.Refresh(); + console.WriteLine("x".Repeat(console.Profile.Width + 10), new Style(foreground: Color.White)); + }); + + // Then + return Verifier.Verify(console.Output); + } }