Correct syntax highlighting when adding a new line in the middle of the file

This commit is contained in:
Timothy Warren 2021-03-09 11:05:23 -05:00
parent 1680035546
commit e4ffe8eb98
1 changed files with 7 additions and 3 deletions

View File

@ -207,6 +207,12 @@ class Editor {
$row, $row,
...array_slice($this->rows, $at), ...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); ksort($this->rows);
@ -236,7 +242,7 @@ class Editor {
$this->rows = array_values($this->rows); $this->rows = array_values($this->rows);
for ($i = $at; $i < $this->numRows; $i++) for ($i = $at; $i < $this->numRows; $i++)
{ {
$this->rows[$i]->idx--; $this->rows[$i]->idx = $i;
} }
// Re-tokenize the file // Re-tokenize the file
@ -673,8 +679,6 @@ class Editor {
public function refreshScreen(): void public function refreshScreen(): void
{ {
Terminal::clear();
$this->scroll(); $this->scroll();
$this->outputBuffer = ''; $this->outputBuffer = '';