From e2e4f421e081d2514b31127b3727f4632833ac73 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Fri, 8 Nov 2019 12:04:26 -0500 Subject: [PATCH] Insert a little more sanity --- src/Editor.php | 1 - src/Row.php | 24 ++---------------------- 2 files changed, 2 insertions(+), 23 deletions(-) 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(); }