Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ Interface.prototype.undoHistory = function() {

// If it's a multiline code, then add history
// accordingly.
Interface.prototype.multilineHistory = function() {
// check if we got a multiline code
if (this.multiline !== '' && this.terminal) {
Interface.prototype.multilineHistory = function(clearBuffer) {
// if not clear buffer, add multiline history
if (!clearBuffer && this.terminal) {
const dupIndex = this.history.indexOf(this.multiline);
if (dupIndex !== -1) this.history.splice(dupIndex, 1);
// Remove the last entered line as multiline
Expand Down
8 changes: 7 additions & 1 deletion lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,13 @@ function REPLServer(prompt,
}
}

// handle multiline history
if (self[kBufferedCommandSymbol].length)
REPLServer.super_.prototype.multilineHistory.call(self, false);
else {
REPLServer.super_.prototype.multilineHistory.call(self, true);
}

// Clear buffer if no SyntaxErrors
self.clearBufferedCommand();
sawCtrlD = false;
Expand Down Expand Up @@ -774,7 +781,6 @@ exports.start = function(prompt,

REPLServer.prototype.clearBufferedCommand = function clearBufferedCommand() {
this[kBufferedCommandSymbol] = '';
REPLServer.super_.prototype.multilineHistory.call(this);
};

REPLServer.prototype.close = function close() {
Expand Down