Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNathan Rajlich <nathan@tootallnate.net>2012-03-27 23:41:42 +0400
committerNathan Rajlich <nathan@tootallnate.net>2012-03-28 00:54:49 +0400
commitf41901cdf6e6236de3f588051b81340e9c1dd61f (patch)
tree7d08cf01f39a33aa94285ad536e69dfa7bb1953f /lib
parent00224771e32e4d051e5ea33b7e854f0031359912 (diff)
repl: make ^D emit an 'end' event on the readline instance
Also emit 'exit' on the repl when 'end' is emitted on the readline. Fixes `node debug test/fixtures/breakpoints.js` when ^D is pressed.
Diffstat (limited to 'lib')
-rw-r--r--lib/readline.js4
-rw-r--r--lib/repl.js5
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/readline.js b/lib/readline.js
index 94d88ed2592..f7dbe0585d8 100644
--- a/lib/readline.js
+++ b/lib/readline.js
@@ -90,6 +90,9 @@ function Interface(input, output, completer, terminal) {
input.on('data', function(data) {
self._normalWrite(data);
});
+ input.on('end', function() {
+ self.emit('end');
+ });
} else {
@@ -575,6 +578,7 @@ Interface.prototype._ttyWrite = function(s, key) {
case 'd': // delete right or EOF
if (this.cursor === 0 && this.line.length === 0) {
this.pause();
+ this.emit('end');
} else if (this.cursor < this.line.length) {
this._deleteRight();
}
diff --git a/lib/repl.js b/lib/repl.js
index c96cbe14f41..84293e2c4ea 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -168,6 +168,11 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) {
rli.setPrompt(self.prompt);
+ rli.on('end', function() {
+ self.rli.output.write('\n');
+ self.emit('exit');
+ });
+
var sawSIGINT = false;
rli.on('SIGINT', function() {
var empty = rli.line.length === 0;