repl: handle buffered string logic on finish
Looks like `clearBufferedCommand` will be called on almost all flows. Hence history was broken. PR-URL: https://github.com/nodejs/node/pull/24389 Fixes: https://github.com/nodejs/node/issues/24385 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
parent
7778c035a0
commit
eb42c1eb4f
@ -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
|
||||
|
@ -667,6 +667,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;
|
||||
@ -773,7 +780,6 @@ exports.start = function(prompt,
|
||||
|
||||
REPLServer.prototype.clearBufferedCommand = function clearBufferedCommand() {
|
||||
this[kBufferedCommandSymbol] = '';
|
||||
REPLServer.super_.prototype.multilineHistory.call(this);
|
||||
};
|
||||
|
||||
REPLServer.prototype.close = function close() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user