diff --git a/src/Editor.php b/src/Editor.php index 7e2ef92..9dcb779 100644 --- a/src/Editor.php +++ b/src/Editor.php @@ -207,6 +207,12 @@ class Editor { $row, ...array_slice($this->rows, $at), ]; + + // Update indexes of each row so that correct highlighting is done + for ($idx = $at; $idx < $this->numRows; $idx++) + { + $this->rows[$idx]->idx = $idx; + } } ksort($this->rows); @@ -236,7 +242,7 @@ class Editor { $this->rows = array_values($this->rows); for ($i = $at; $i < $this->numRows; $i++) { - $this->rows[$i]->idx--; + $this->rows[$i]->idx = $i; } // Re-tokenize the file @@ -673,8 +679,6 @@ class Editor { public function refreshScreen(): void { - Terminal::clear(); - $this->scroll(); $this->outputBuffer = '';