Commit 1b007b32 authored by Pietro Saccardi's avatar Pietro Saccardi
Browse files

Bugfix: would not correctly find brackets.

parent feee525d
Loading
Loading
Loading
Loading
+6 −11
Original line number Diff line number Diff line
@@ -357,19 +357,14 @@ class ElementDefinition {
        if ($args[$position]->definition() != $openTokDef) {
            return 0;
        }
        if ($nested) {
            // Get the longest sequence
            for ($i = count($args) - 1; $i > $position; --$i) {
                if ($args[$i]->definition() == $closeTokDef) {
                    return $i - $position + 1;
                }
            }
        } else {
            // Get the shortest sequence
        $nest = 1;
        for ($i = $position + 1; $i < count($args); ++$i) {
            if ($args[$i]->definition() == $closeTokDef) {
                if (--$nest <= 0) {
                    return $i - $position + 1;
                }
            } else if ($nested && $args[$i]->definition() == $openTokDef) {
                ++$nest;
            }
        }
        return 1;  // Which means unmatched sequence