summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2014-07-31 12:30:46 +0400
committerFedor Indutny <fedor@indutny.com>2014-07-31 12:30:46 +0400
commit1a84ba2d66129c36581a42dd7aa3a6707cfd1704 (patch)
treeae2cbd149e82546ac0cfde7dc89e5dfcbc2e2fd6 /lib
parent1a52d6abccf8f314f6b6274076ab88664261437f (diff)
downloadnodejs-1a84ba2d66129c36581a42dd7aa3a6707cfd1704.tar.gz
nodejs-1a84ba2d66129c36581a42dd7aa3a6707cfd1704.tar.bz2
nodejs-1a84ba2d66129c36581a42dd7aa3a6707cfd1704.zip
repl: proper `setPrompt()` and `multiline` support
fix #8031
Diffstat (limited to 'lib')
-rw-r--r--lib/repl.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/repl.js b/lib/repl.js
index 6d49bdac9..578f99ed2 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -389,16 +389,22 @@ REPLServer.prototype.resetContext = function() {
};
REPLServer.prototype.displayPrompt = function(preserveCursor) {
- var initial = this._prompt;
- var prompt = initial;
+ var prompt = this._initialPrompt;
if (this.bufferedCommand.length) {
prompt = '...';
var levelInd = new Array(this.lines.level.length).join('..');
prompt += levelInd + ' ';
}
- this.setPrompt(prompt);
+
+ // Do not overwrite `_initialPrompt` here
+ REPLServer.super_.prototype.setPrompt.call(this, prompt);
this.prompt(preserveCursor);
- this.setPrompt(initial);
+};
+
+// When invoked as an API method, overwrite _initialPrompt
+REPLServer.prototype.setPrompt = function setPrompt(prompt) {
+ this._initialPrompt = prompt;
+ REPLServer.super_.prototype.setPrompt.call(this, prompt);
};
// A stream to push an array into a REPL