From 228576ccf13a6fef92f929c7172844cde340d5e5 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 16 Apr 2021 12:51:53 -0400 Subject: [PATCH] Fix page down behavior, resolves #1 --- src/Editor.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Editor.php b/src/Editor.php index 99f3817..b396f5c 100644 --- a/src/Editor.php +++ b/src/Editor.php @@ -778,7 +778,7 @@ class Editor { break; default: - // Do nothing + return; } // Snap cursor to the end of a row when moving @@ -792,8 +792,9 @@ class Editor { } $this->cursor->x = $x; - $this->cursor->y = $y; } + + $this->cursor->y = ($y >= $this->document->numRows) ? $this->document->numRows - 1 : $y; } protected function insertChar(string $c): void