Skip to content

Commit 71a5d83

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

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed
 

‎src/Spectre.Console/Live/LiveRenderable.cs

+1-1
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

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

+26
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)
Please sign in to comment.