diff --git a/src/Row.php b/src/Row.php index d9296dc..062bc00 100644 --- a/src/Row.php +++ b/src/Row.php @@ -526,13 +526,14 @@ class Row { { continue; } - $charEnd = $charStart + $charLen; // Probably not great to create a closure in a loop like this, but // this halves the boilerplate for each type of syntax - $highlightRange = function (int $hl) use ($charLen, $charStart, $charEnd, &$offset) { + $highlightRange = function (int $hl) use ($charLen, $charStart, &$offset) { array_replace_range($this->hl, $charStart, $charLen, $hl); - $offset = $charEnd; + + // Update the offset to the end of the current token + $offset = $charStart + $charLen; }; // Start of multiline comment/single line comment