Add line number gutter offset to row deletion
Some checks failed
timw4mail/php-kilo/pipeline/head There was a failure building this commit
Some checks failed
timw4mail/php-kilo/pipeline/head There was a failure building this commit
This commit is contained in:
parent
223371fb4a
commit
045bf89f45
@ -119,7 +119,7 @@ class Document {
|
|||||||
$this->dirty = true;
|
$this->dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(Point $at): void
|
public function delete(Point $at, int $gutter = 0): void
|
||||||
{
|
{
|
||||||
if ($at->y > $this->numRows)
|
if ($at->y > $this->numRows)
|
||||||
{
|
{
|
||||||
@ -128,7 +128,7 @@ class Document {
|
|||||||
|
|
||||||
$row =& $this->rows[$at->y];
|
$row =& $this->rows[$at->y];
|
||||||
|
|
||||||
if ($at->x === $this->rows[$at->y]->size && $at->y + 1 < $this->numRows)
|
if (($at->x - $gutter) === $this->rows[$at->y]->size && $at->y + 1 < $this->numRows)
|
||||||
{
|
{
|
||||||
$this->rows[$at->y]->append($this->rows[$at->y + 1]->chars);
|
$this->rows[$at->y]->append($this->rows[$at->y + 1]->chars);
|
||||||
$this->deleteRow($at->y + 1);
|
$this->deleteRow($at->y + 1);
|
||||||
|
@ -779,13 +779,13 @@ class Editor {
|
|||||||
{
|
{
|
||||||
if ($ch === KeyType::Delete)
|
if ($ch === KeyType::Delete)
|
||||||
{
|
{
|
||||||
$this->document->delete($this->cursor);
|
$this->document->delete($this->cursor, $this->numberGutter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ch === KeyType::Backspace && ($this->cursor->x > 0 || $this->cursor->y > 0))
|
if ($ch === KeyType::Backspace && (($this->cursor->x >= $this->numberGutter) || $this->cursor->y > 0))
|
||||||
{
|
{
|
||||||
$this->moveCursor(KeyType::ArrowLeft);
|
$this->moveCursor(KeyType::ArrowLeft);
|
||||||
$this->document->delete($this->cursor);
|
$this->document->delete($this->cursor, $this->numberGutter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user