/**
 * copyObject(object, [recurse]) -- for all JS Objects
 *
 * Copies all properties and the prototype to a new object
 * Optionally set recurse to array containing the properties, on wich this function should be called recursively
 */
function copyObject(object, recurse) {
  var new_obj = Object.create(Object.getPrototypeOf(object));
  recurse = (recurse) ? recurse : [];
  for(var prop in object) {
    new_obj[prop] = object[prop];
    if(recurse.indexOf(prop) !== -1) new_obj[prop] = copyObject(object[prop]);
  }
  return new_obj;
}

function repeatString(str, times) {
  for(var padding = "", i=0; i < times; i++) {
    padding += str;
  }
  return padding;
}

function isInt(n) {
  return String(parseInt(n)) === String(n) && parseInt(n) >= 0 && isFinite(n);
}

function calcLineNo(source, offset) {
  return offset ? source.substr( 0, offset ).split("\n").length : -1;
};

function getLineExcerpt(source, offset) {
  return source.substr( 0, offset ).split("\n").pop() + source.substr( offset, 250 ).split("\n")[0];
};

function getLineCol(source, offset) {
  return source.substr( 0, offset ).split("\n").pop().length+1
};
@@ -926,61 +926,69 @@
 %7B%0A  
-return source.substr( 0, offset ).split(%22%5Cn%22).pop() +
+var line = calcLineNo(source, offset);%0A  return (line %3E= 0) ?
  sou
@@ -996,43 +996,50 @@
 ce.s
-ubstr( offset, 250 ).split(%22%5Cn%22)%5B0%5D
+plit(%22%5Cn%22)%5Bline-1%5D : '%3CNo code reference%3E'
 ;%0A%7D;

Use calcLineNo() for getLineExcerpt() to handle undefined offset