diff --git a/src/Editor.php b/src/Editor.php index 0bb08b4..e3290d3 100644 --- a/src/Editor.php +++ b/src/Editor.php @@ -277,7 +277,6 @@ class Editor { // Truncate the previous row $row->chars = $newChars; - $row->update(); // Add a new row, with the contents from the cursor to the end of the line $this->insertRow($this->cursorY + 1, substr($chars, $this->cursorX), FALSE); diff --git a/src/Row.php b/src/Row.php index 29ba48a..4fba4dc 100644 --- a/src/Row.php +++ b/src/Row.php @@ -256,28 +256,8 @@ class Row { public function update(): void { - $idx = 0; - - // Make sure the render buffer is empty before updating - // otherwise, you will have persistent output where you - // don't want it. - $this->render = ''; - - for ($i = 0; $i < $this->size; $i++) - { - if ($this->chars[$i] === "\t") - { - $this->render[$idx++] = ' '; - while ($idx % KILO_TAB_STOP !== 0) - { - $this->render[$idx++] = ' '; - } - } - else - { - $this->render[$idx++] = $this->chars[$i]; - } - } + $replacement = str_repeat(' ', KILO_TAB_STOP); + $this->render = str_replace("\t", $replacement, $this->chars); $this->updateSyntax(); }