Skip to content

Commit

Permalink
Handle cursor being moved to end of buffer.
Browse files Browse the repository at this point in the history
Handle when `MoveCursor()` attempts to move the cursor to the end of the
terminal buffer, same as `Render()`, by issueing a line feed to force a
scroll.

Fixes #1144.
  • Loading branch information
msftrncs committed Nov 8, 2019
1 parent 65be868 commit bd62ec2
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion PSReadLine/Render.cs
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,25 @@ private void MoveCursor(int newCursor)
return;
}

_console.SetCursorPosition(point.X, point.Y);
if (point.Y == _console.BufferHeight)
{
// The cursor top exceeds the buffer height, so adjust the initial cursor
// position and the to-be-set cursor position for scrolling up the buffer.
_initialY -= 1;
point.Y -= 1;

// Insure the cursor is on the last line of the buffer prior
// to issuing a newline to scroll the buffer.
_console.SetCursorPosition(point.X, point.Y);

// Scroll up the buffer by 1 line.
_console.Write("\n");
}
else
{
_console.SetCursorPosition(point.X, point.Y);
}

_current = newCursor;
}

Expand Down

0 comments on commit bd62ec2

Please sign in to comment.