Skip to content

Commit 7ba3996

Browse files
ScrollDisplayToCursor bug: don't try to scroll to before the buffer.
1 parent 7992bec commit 7ba3996

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

PSReadLine/Render.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,19 @@ public static void ScrollDisplayToCursor(ConsoleKeyInfo? key = null, object arg
975975
var console = _singleton._console;
976976
var newTop = coordinates.Y - console.WindowHeight + 1;
977977

978+
// If the cursor is already visible, and we're on the first
979+
// page-worth of the buffer, then just scroll to the top (we can't
980+
// scroll to before the beginning of the buffer).
981+
//
982+
// Note that we don't want to just return, because the window may
983+
// have been scrolled way past the end of the content, so we really
984+
// do need to set the new window top to 0 to bring it back into
985+
// view.
986+
if (newTop < 0)
987+
{
988+
newTop = 0;
989+
}
990+
978991
// But if the cursor won't be visible, make sure it is.
979992
if (newTop > console.CursorTop)
980993
{

0 commit comments

Comments
 (0)