More looping updates

This commit is contained in:
Timothy Warren 2019-11-05 13:21:37 -05:00
parent 2871ead27d
commit be415d28b8
2 changed files with 9 additions and 8 deletions

View File

@ -186,6 +186,12 @@ class Editor {
$row = Row::new($this, $s, $at); $row = Row::new($this, $s, $at);
// Update row indicies
for ($i = $at + 1; $i < $this->numRows; $i++)
{
$this->rows[$i]->idx++;
}
if ($at === $this->numRows) if ($at === $this->numRows)
{ {
$this->rows[] = $row; $this->rows[] = $row;
@ -197,12 +203,6 @@ class Editor {
$row, $row,
...array_slice($this->rows, $at), ...array_slice($this->rows, $at),
]; ];
// Update row indicies
foreach ($this->rows as $i => $row)
{
$row->idx = $i;
}
} }
$this->rows[$at]->update(); $this->rows[$at]->update();

View File

@ -429,11 +429,12 @@ class Row {
protected function updateSyntaxPHP():void protected function updateSyntaxPHP():void
{ {
// The index for the tokens should exist if ( ! isset($this->parent->syntax->tokens))
if ( ! array_key_exists($this->idx + 1, $this->parent->syntax->tokens))
{ {
return; return;
} }
// The index for the tokens should exist
$tokens = $this->parent->syntax->tokens[$this->idx + 1]; $tokens = $this->parent->syntax->tokens[$this->idx + 1];
// $inComment = ($this->idx > 0 && $this->parent->rows[$this->idx - 1]->hlOpenComment); // $inComment = ($this->idx > 0 && $this->parent->rows[$this->idx - 1]->hlOpenComment);