Fixed render issue where writeline inside status caused corrupt output #415 #694

This commit is contained in:
fredrikbentzen 2023-01-11 22:09:09 +01:00 committed by Patrik Svensson
parent 35ce60b596
commit 71a5d83067
4 changed files with 41 additions and 3 deletions

View File

@ -49,7 +49,7 @@ internal sealed class LiveRenderable : Renderable
}
var linesToMoveUp = _shape.Value.Height - 1;
return new ControlCode("\r" + CUU(linesToMoveUp));
return new ControlCode("\r" + (EL(2) + CUU(1)).Repeat(linesToMoveUp));
}
}

View File

@ -1,10 +1,10 @@
[?25l
* foo


- bar


* baz
[?25h

View File

@ -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

View File

@ -49,4 +49,30 @@ public sealed class StatusTests
// 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);
}
}