* 1.11.1 (2012-XX-XX)
+ * fixed debug info line numbering (was off by 2)
* fixed escaping when calling a macro inside another one (regression introduced in 1.9.1)
* optimized variable access on PHP 5.4
* fixed a crash of the C extension when an exception was thrown from a macro called without being imported (using _self.XXX)
$this->lastLine = null;
$this->source = '';
$this->sourceOffset = 0;
- $this->sourceLine = 0;
+ // source code starts at 1 (as we then increment it when we encounter new lines)
+ $this->sourceLine = 1;
$this->indentation = $indentation;
if ($node instanceof Twig_Node_Module) {
public function addDebugInfo(Twig_NodeInterface $node)
{
if ($node->getLine() != $this->lastLine) {
+ $this->write("// line {$node->getLine()}\n");
+
// when mbstring.func_overload is set to 2
// mb_substr_count() replaces substr_count()
// but they have different signatures!
$this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset);
}
$this->sourceOffset = strlen($this->source);
- $this->debugInfo[$this->sourceLine + 2] = $node->getLine();
+ $this->debugInfo[$this->sourceLine] = $node->getLine();
$this->lastLine = $node->getLine();
- $this->write("// line {$node->getLine()}\n");
}
return $this;