function editorLineNumberForError(error) {
  if (!error) return null;
  var parsed = parsestack(error);
  if (!parsed) return null;
  if (!debug.scope || !debug.scope.CoffeeScript || !debug.scope.CoffeeScript.code) return null;
  // Find the innermost call that corresponds to compiled CoffeeScript.
  var frame = null;
  for (var j = 0; j < parsed.length; ++j) {
    if (parsed[j].file in debug.scope.CoffeeScript.code) {
      frame = parsed[j];
    }
  }
  if (!frame) return null;
  var map = debug.scope.CoffeeScript.code[frame.file].map;
  if (!map) return null;
  var smc = new sourcemap.SourceMapConsumer(map);

  // The CoffeeScript source code mappings are empirically a bit inaccurate,
  // but it seems if we look for the maximum original line number for any
  // column in the generated line, that seems to be fairly accurate.
  var line = null;
  for (var col = 0; col < 80; col++) {
    var mapped = smc.originalPositionFor({line: frame.line, column: col});
    if (mapped && mapped.line) {
      line = line == null ? mapped.line : Math.max(line, mapped.line);
    }
  }

  if (!line || line < 4) return null;
  // Subtract a few lines of boilerplate from the top of the script.
  return line - 3;
}
// or returns null if none can be figured out.
or returns null if none can be figured out.
or returns null if none can be figured out .
function editorLineNumberForError(error) {
  if (!error) return null;
  var parsed = parsestack(error);
  if (!parsed) return null;
  if (!debug.scope || !debug.scope.CoffeeScript || !debug.scope.CoffeeScript.code) return null;
  var frame = null;
  for (var j = 0; j < parsed.length; ++j) {
    if (parsed[j].file in debug.scope.CoffeeScript.code) {
      frame = parsed[j];
    }
  }
  if (!frame) return null;
  var map = debug.scope.CoffeeScript.code[frame.file].map;
  if (!map) return null;
  var smc = new sourcemap.SourceMapConsumer(map);
  var line = null;
  for (var col = 0; col < 80; col++) {
    var mapped = smc.originalPositionFor({line: frame.line, column: col});
    if (mapped && mapped.line) {
      line = line == null ? mapped.line : Math.max(line, mapped.line);
    }
  }
  if (!line || line < 4) return null;
  return line - 3;
}
function editorLineNumberForError ( error ) { if ( ! error ) return null ; var parsed = parsestack ( error ) ; if ( ! parsed ) return null ; if ( ! debug . scope || ! debug . scope . CoffeeScript || ! debug . scope . CoffeeScript . code ) return null ; var frame = null ; for ( var j = 0 ; j < parsed . length ; ++ j ) { if ( parsed [ j ] . file in debug . scope . CoffeeScript . code ) { frame = parsed [ j ] ; } } if ( ! frame ) return null ; var map = debug . scope . CoffeeScript . code [ frame . file ] . map ; if ( ! map ) return null ; var smc = new sourcemap . SourceMapConsumer ( map ) ; var line = null ; for ( var col = 0 ; col < 80 ; col ++ ) { var mapped = smc . originalPositionFor ( { line : frame . line , column : col } ) ; if ( mapped && mapped . line ) { line = line == null ? mapped . line : Math . max ( line , mapped . line ) ; } } if ( ! line || line < 4 ) return null ; return line - 3 ; }
or returns null if none can be figured out.
or returns null if none can be figured out .
// Find the innermost call that corresponds to compiled CoffeeScript. // The CoffeeScript source code mappings are empirically a bit inaccurate, // but it seems if we look for the maximum original line number for any // column in the generated line, that seems to be fairly accurate. // Subtract a few lines of boilerplate from the top of the script.