Skip to content

Commit

Permalink
When placing the console cursor on a new line, write a newline to ens…
Browse files Browse the repository at this point in the history
…ure it's initialized (#226)
  • Loading branch information
kimsey0 committed Sep 26, 2022
1 parent 5eb4a84 commit 2c5fcff
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Sharprompt/Internal/OffscreenBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,18 @@ public void RenderToConsole()
var physicalLeft = _pushedCursor.Left % _consoleDriver.BufferWidth;
var physicalTop = _pushedCursor.Top + (_pushedCursor.Left / _consoleDriver.BufferWidth);

_consoleDriver.SetCursorPosition(physicalLeft, _cursorBottom - WrittenLineCount + physicalTop);
var consoleTop = _cursorBottom - WrittenLineCount + physicalTop;
if (_pushedCursor.Left > 0 && physicalLeft == 0)
{
_consoleDriver.WriteLine();
if (consoleTop == _consoleDriver.BufferHeight)
{
_cursorBottom--;
consoleTop--;
}
}

_consoleDriver.SetCursorPosition(physicalLeft, consoleTop);
}
}

Expand Down

0 comments on commit 2c5fcff

Please sign in to comment.