Fix resizing of Live views with reduced size. (#1840)

This commit is contained in:
Daniel
2025-06-21 12:30:18 +02:00
committed by GitHub
parent 7f3ebe02c4
commit f32f80dc57
4 changed files with 12 additions and 5 deletions

View File

@ -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;
@ -45,7 +44,7 @@ internal sealed class LiveDisplayRenderer : IRenderHook
{
lock (_context.Lock)
{
yield return _context.Live.PositionCursor();
yield return _context.Live.PositionCursor(options);
foreach (var renderable in renderables)
{

View File

@ -39,7 +39,7 @@ internal sealed class LiveRenderable : Renderable
}
}
public IRenderable PositionCursor()
public IRenderable PositionCursor(RenderOptions options)
{
lock (_lock)
{
@ -48,6 +48,14 @@ internal sealed class LiveRenderable : Renderable
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));
}

View File

@ -118,7 +118,7 @@ internal sealed class DefaultProgressRenderer : ProgressRenderer
{
lock (_lock)
{
yield return _live.PositionCursor();
yield return _live.PositionCursor(options);
foreach (var renderable in renderables)
{

View File

@ -42,7 +42,7 @@ internal sealed class ListPromptRenderHook<T> : IRenderHook
_dirty = false;
}
yield return _live.PositionCursor();
yield return _live.PositionCursor(options);
foreach (var renderable in renderables)
{