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