Permalink
Browse files

Fix calculation of line numbers of errors in evaluated expressions

Broken in 3118f39.
  • Loading branch information...
1 parent 3118f39 commit 2f6ff47aebc21e1343265d98aa573ba5770ef5cd @simonlindholm simonlindholm committed Jan 4, 2013
Showing with 7 additions and 3 deletions.
  1. +7 −3 extension/content/firebug/console/commandLineExposed.js
@@ -185,10 +185,14 @@ function createFirebugCommandLine(context, win)
function evaluate(expr, origExpr)
{
var result;
- var line = Components.stack.lineNumber;
+ var baseLine;
try
{
- result = contentView.eval(expr);
+ // Errors thrown from within the expression of the eval call will
+ // have a line number equal to (line of eval, 1-based) + (line in
+ // expression, 0-based) - keep track of the former term so we can
+ // correct it later.
+ baseLine = Components.stack.lineNumber; result = contentView.eval(expr);
// See Issue 5221
//var result = FirebugEvaluate(expr, contentView);
@@ -223,7 +227,7 @@ function createFirebugCommandLine(context, win)
result.stack = null;
result.source = expr;
result.message = exc.message;
- result.lineNumber = lineNumber - line;
+ result.lineNumber = lineNumber - baseLine + 1;
// Lie and show the pre-transformed expression instead.
result.fileName = "data:," + encodeURIComponent(origExpr);

0 comments on commit 2f6ff47

Please sign in to comment.