From 6fed6f5e1f4a89f04dd56ee14acf0bc410b550ae Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 3 Dec 2018 13:08:14 +0100 Subject: [PATCH] Revert "repl: handle buffered string logic on finish" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit eb42c1eb4f2502433a22c49ede9e657fb6cd86e0. PR-URL: https://github.com/nodejs/node/pull/24804 Refs: https://github.com/nodejs/node/issues/24231 Reviewed-By: Anto Aravinth Reviewed-By: Michaƫl Zasso Reviewed-By: Jeremiah Senkpiel --- lib/readline.js | 6 +++--- lib/repl.js | 8 +------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/readline.js b/lib/readline.js index 049f5aaeccf439..322f145263e969 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -356,9 +356,9 @@ Interface.prototype.undoHistory = function() { // If it's a multiline code, then add history // accordingly. -Interface.prototype.multilineHistory = function(clearBuffer) { - // if not clear buffer, add multiline history - if (!clearBuffer && this.terminal) { +Interface.prototype.multilineHistory = function() { + // check if we got a multiline code + if (this.multiline !== '' && this.terminal) { const dupIndex = this.history.indexOf(this.multiline); if (dupIndex !== -1) this.history.splice(dupIndex, 1); // Remove the last entered line as multiline diff --git a/lib/repl.js b/lib/repl.js index 5dbd02fd231cd1..cd341978cb6f71 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -667,13 +667,6 @@ 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; @@ -780,6 +773,7 @@ exports.start = function(prompt, REPLServer.prototype.clearBufferedCommand = function clearBufferedCommand() { this[kBufferedCommandSymbol] = ''; + REPLServer.super_.prototype.multilineHistory.call(this); }; REPLServer.prototype.close = function close() {