[debugger] separate history of control and debug, make scripts command getter
authorFedor Indutny <fedor.indutny@gmail.com>
Wed, 14 Sep 2011 09:35:51 +0000 (16:35 +0700)
committerFedor Indutny <fedor.indutny@gmail.com>
Wed, 14 Sep 2011 16:05:04 +0000 (23:05 +0700)
lib/_debugger.js

index 55140db..174c56b 100644 (file)
@@ -735,6 +735,10 @@ function Interface() {
   this.waiting = null;
   this.paused = 0;
   this.context = this.repl.context;
+  this.history = {
+    debug: [],
+    control: []
+  };
 };
 
 
@@ -1015,11 +1019,12 @@ Interface.prototype.backtrace = function() {
 
 
 // argument full tells if it should display internal node scripts or not
-Interface.prototype.scripts = function(displayNatives) {
+Interface.prototype.scripts = function() {
   if (!this.requireConnection()) return;
 
-  var client = this.client;
-  var scripts = [];
+  var client = this.client,
+      displayNatives = arguments[0] || false,
+      scripts = [];
 
   this.pause();
   for (var id in client.scripts) {
@@ -1228,6 +1233,10 @@ Interface.prototype.repl = function() {
   this.repl.eval = this.debugEval.bind(this);
   this.repl.context = {};
 
+  // Swap history
+  this.history.control = this.repl.rli.history;
+  this.repl.rli.history = this.history.debug;
+
   this.repl.prompt = '> ';
   this.repl.rli.setPrompt('> ');
   this.repl.displayPrompt();
@@ -1236,8 +1245,13 @@ Interface.prototype.repl = function() {
 
 // Exit debug repl
 Interface.prototype.exitRepl = function() {
+  // Restore eval
   this.repl.eval = this.controlEval.bind(this);
 
+  // Swap history
+  this.history.debug = this.repl.rli.history;
+  this.repl.rli.history = this.history.control;
+
   this.repl.context = this.context;
   this.repl.prompt = 'debug> ';
   this.repl.rli.setPrompt('debug> ');