Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Spectre.Console/Live/LiveDisplayRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ internal sealed class LiveDisplayRenderer : IRenderHook
{
private readonly IAnsiConsole _console;
private readonly LiveDisplayContext _context;

public LiveDisplayRenderer(IAnsiConsole console, LiveDisplayContext context)
{
_console = console;
Expand Down Expand Up @@ -45,7 +44,7 @@ public IEnumerable<IRenderable> Process(RenderOptions options, IEnumerable<IRend
{
lock (_context.Lock)
{
yield return _context.Live.PositionCursor();
yield return _context.Live.PositionCursor(options);

foreach (var renderable in renderables)
{
Expand Down
10 changes: 9 additions & 1 deletion src/Spectre.Console/Live/LiveRenderable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void SetRenderable(IRenderable? renderable)
}
}

public IRenderable PositionCursor()
public IRenderable PositionCursor(RenderOptions options)
{
lock (_lock)
{
Expand All @@ -48,6 +48,14 @@ public IRenderable PositionCursor()
return new ControlCode(string.Empty);
}

// Check if the size have been reduced
if (_shape.Value.Height > options.ConsoleSize.Height || _shape.Value.Width > options.ConsoleSize.Width)
{
// Important reset shape, so the size can shrink
_shape = null;
return new ControlCode(ED(2) + ED(3) + CUP(1, 1));
}

var linesToMoveUp = _shape.Value.Height - 1;
return new ControlCode("\r" + CUU(linesToMoveUp));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public override IEnumerable<IRenderable> Process(RenderOptions options, IEnumera
{
lock (_lock)
{
yield return _live.PositionCursor();
yield return _live.PositionCursor(options);

foreach (var renderable in renderables)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Spectre.Console/Prompts/List/ListPromptRenderHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public IEnumerable<IRenderable> Process(RenderOptions options, IEnumerable<IRend
_dirty = false;
}

yield return _live.PositionCursor();
yield return _live.PositionCursor(options);

foreach (var renderable in renderables)
{
Expand Down