Skip to content

Commit 71a5d83

Browse files
fredrikbentzenpatriksvensson
authored andcommitted
Fixed render issue where writeline inside status caused corrupt output #415 #694
1 parent 35ce60b commit 71a5d83

4 files changed

Lines changed: 41 additions & 3 deletions

File tree

src/Spectre.Console/Live/LiveRenderable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public IRenderable PositionCursor()
4949
}
5050

5151
var linesToMoveUp = _shape.Value.Height - 1;
52-
return new ControlCode("\r" + CUU(linesToMoveUp));
52+
return new ControlCode("\r" + (EL(2) + CUU(1)).Repeat(linesToMoveUp));
5353
}
5454
}
5555

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[?25l
22
* foo
33

4-

4+

55
- bar
66

7-

7+

88
* baz
99

1010
[?25h
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[?25l
2+
⣷ long text that should not interfere writeline text
3+
4+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
5+
xxxxxxxxxx
6+
7+
⣷ long text that should not interfere writeline text
8+
9+

10+
⣷ long text that should not interfere writeline text
11+
12+
[?25h

test/Spectre.Console.Tests/Unit/Live/StatusTests.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,30 @@ public Task Should_Render_Status_Correctly()
4949
// Then
5050
return Verifier.Verify(console.Output);
5151
}
52+
53+
[Fact]
54+
[Expectation("WriteLineOverflow")]
55+
public Task Should_Render_Correctly_When_WriteLine_Exceeds_Console_Width()
56+
{
57+
// Given
58+
var console = new TestConsole()
59+
.Colors(ColorSystem.TrueColor)
60+
.Width(100)
61+
.Interactive()
62+
.EmitAnsiSequences();
63+
var status = new Status(console)
64+
{
65+
AutoRefresh = false,
66+
};
67+
68+
// When
69+
status.Start("long text that should not interfere writeline text", ctx =>
70+
{
71+
ctx.Refresh();
72+
console.WriteLine("x".Repeat(console.Profile.Width + 10), new Style(foreground: Color.White));
73+
});
74+
75+
// Then
76+
return Verifier.Verify(console.Output);
77+
}
5278
}

0 commit comments

Comments
 (0)