Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
repl: proper setPrompt() and multiline support
Browse files Browse the repository at this point in the history
fix #8031
  • Loading branch information
indutny committed Jul 31, 2014
1 parent 1a52d6a commit 1a84ba2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1a84ba2

Please sign in to comment.