From 8efe7a8304e33fce36a8b7add9ed2ba63b647e3d Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Wed, 21 Sep 2011 17:59:04 +0700 Subject: [PATCH] [debugger] shorten break message --- lib/_debugger.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/_debugger.js b/lib/_debugger.js index ef456c6972..26d2248130 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -19,10 +19,11 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -var net = require('net'), - repl = require('repl'), +var util = require('util'), + path = require('path'), + net = require('net'), vm = require('vm'), - util = require('util'), + repl = require('repl'), inherits = util.inherits, spawn = require('child_process').spawn; @@ -671,24 +672,22 @@ function SourceUnderline(sourceText, position) { } -function SourceInvocation(body) { - return body.invocationText.replace(/\n/g, '') - .replace(/^([^(]*)\(.*\)([^)]*)$/, '$1(...)$2'); -} - - function SourceInfo(body) { - var result = 'break in ' + SourceInvocation(body); + var result = 'break in '; if (body.script) { if (body.script.name) { - var name = body.script.name; + var name = body.script.name, + dir = path.resolve() + '/'; - // TODO Change path to relative, if possible + // Change path to relative, if possible + if (name.indexOf(dir) === 0) { + name = name.slice(dir.length); + } - result += ', ' + name; + result += name; } else { - result += ', [unnamed]'; + result += '[unnamed]'; } } result += ':'; @@ -1096,7 +1095,7 @@ Interface.prototype.backtrace = function() { if (frame.func.inferredName && frame.func.inferredName.length > 0) { text += frame.func.inferredName + ' '; } - text += require('path').basename(frame.script.name) + ':'; + text += path.basename(frame.script.name) + ':'; text += (frame.line + 1) + ':' + (frame.column + 1); trace.push(text); @@ -1128,7 +1127,7 @@ Interface.prototype.scripts = function() { scripts.push( (script.name == client.currentScript ? '* ' : ' ') + id + ': ' + - require('path').basename(script.name) + path.basename(script.name) ); } }