Skip to content

Commit

Permalink
Fixed render issue where writeline inside status caused corrupt output
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikbentzen authored and patriksvensson committed Jun 4, 2023
1 parent 35ce60b commit 71a5d83
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Spectre.Console/Live/LiveRenderable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[?25l
* foo



- bar



* baz

[?25h
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions test/Spectre.Console.Tests/Unit/Live/StatusTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 71a5d83

Please sign in to comment.