Fix line splitting on enter
All checks were successful
timw4mail/php-kilo/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2021-04-09 11:26:02 -04:00
parent b63c3e49d8
commit 35ec8f27ad
2 changed files with 3 additions and 11 deletions

View File

@ -3,6 +3,7 @@
namespace Aviat\Kilo; namespace Aviat\Kilo;
use Aviat\Kilo\Enum\KeyCode; use Aviat\Kilo\Enum\KeyCode;
use Aviat\Kilo\Enum\KeyType;
use Aviat\Kilo\Tokens\PHP8; use Aviat\Kilo\Tokens\PHP8;
use Aviat\Kilo\Type\Point; use Aviat\Kilo\Type\Point;
@ -101,18 +102,13 @@ class Document {
return; return;
} }
$this->dirty = true; if ($c === KeyType::ENTER || $c === KeyCode::CARRIAGE_RETURN)
if ($c === KeyCode::ENTER || $c === KeyCode::CARRIAGE_RETURN)
{ {
$this->insertNewline($at); $this->insertNewline($at);
return; return;
} }
if ($at->y === $this->numRows) $this->dirty = true;
{
$this->insertRow($this->numRows, '');
}
$this->rows[$at->y]->insert($at->x, $c); $this->rows[$at->y]->insert($at->x, $c);
} }

View File

@ -657,10 +657,6 @@ class Editor {
// Do nothing // Do nothing
break; break;
case KeyType::ENTER:
$this->insertChar("\n");
break;
default: default:
$this->insertChar($c); $this->insertChar($c);
break; break;