Skip to content

Commit df584df

Browse files
committed
Handle cursor being moved to end of buffer.
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.
1 parent 65be868 commit df584df

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

PSReadLine/Render.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,23 @@ private void MoveCursor(int newCursor)
992992
return;
993993
}
994994

995-
_console.SetCursorPosition(point.X, point.Y);
995+
if (point.Y == _console.BufferHeight)
996+
{
997+
// Adjust the initial cursor position and the to-be-set cursor position
998+
// after scrolling up the buffer.
999+
_initialY -= 1;
1000+
point.Y -= 1;
1001+
_console.SetCursorPosition(point.X, point.Y);
1002+
1003+
// The cursor top exceeds the buffer height, so we need to
1004+
// scroll up the buffer by 1 line.
1005+
_console.Write("\n");
1006+
}
1007+
else
1008+
{
1009+
_console.SetCursorPosition(point.X, point.Y);
1010+
}
1011+
9961012
_current = newCursor;
9971013
}
9981014

0 commit comments

Comments
 (0)