diff --git a/src/Document.php b/src/Document.php index c17f6d4..ebd06d1 100644 --- a/src/Document.php +++ b/src/Document.php @@ -3,6 +3,7 @@ namespace Aviat\Kilo; use Aviat\Kilo\Enum\KeyCode; +use Aviat\Kilo\Enum\KeyType; use Aviat\Kilo\Tokens\PHP8; use Aviat\Kilo\Type\Point; @@ -101,18 +102,13 @@ class Document { return; } - $this->dirty = true; - - if ($c === KeyCode::ENTER || $c === KeyCode::CARRIAGE_RETURN) + if ($c === KeyType::ENTER || $c === KeyCode::CARRIAGE_RETURN) { $this->insertNewline($at); return; } - if ($at->y === $this->numRows) - { - $this->insertRow($this->numRows, ''); - } + $this->dirty = true; $this->rows[$at->y]->insert($at->x, $c); } diff --git a/src/Editor.php b/src/Editor.php index 48ab926..36885fc 100644 --- a/src/Editor.php +++ b/src/Editor.php @@ -657,10 +657,6 @@ class Editor { // Do nothing break; - case KeyType::ENTER: - $this->insertChar("\n"); - break; - default: $this->insertChar($c); break;