GeezerVison is showing github.com — repl: handle buffered string logic on finish · nodejs/node@bd8be40
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/readline.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -348,9 +348,9 @@ Interface.prototype.undoHistory = function() { |
348 | 348 |
|
349 | 349 | // If it's a multiline code, then add history |
350 | 350 | // accordingly. |
351 | | -Interface.prototype.multilineHistory = function() { |
352 | | - // check if we got a multiline code |
353 | | - if (this.multiline !== '' && this.terminal) { |
| 351 | +Interface.prototype.multilineHistory = function(clearBuffer) { |
| 352 | + // if not clear buffer, add multiline history |
| 353 | + if (!clearBuffer && this.terminal) { |
354 | 354 | const dupIndex = this.history.indexOf(this.multiline); |
355 | 355 | if (dupIndex !== -1) this.history.splice(dupIndex, 1); |
356 | 356 | // Remove the last entered line as multiline |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/repl.js +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -668,6 +668,13 @@ function REPLServer(prompt, |
668 | 668 | } |
669 | 669 | } |
670 | 670 |
|
| 671 | + // handle multiline history |
| 672 | + if (self[kBufferedCommandSymbol].length) |
| 673 | + REPLServer.super_.prototype.multilineHistory.call(self, false); |
| 674 | + else { |
| 675 | + REPLServer.super_.prototype.multilineHistory.call(self, true); |
| 676 | + } |
| 677 | + |
671 | 678 | // Clear buffer if no SyntaxErrors |
672 | 679 | self.clearBufferedCommand(); |
673 | 680 | sawCtrlD = false; |
@@ -774,7 +781,6 @@ exports.start = function(prompt, |
774 | 781 |
|
775 | 782 | REPLServer.prototype.clearBufferedCommand = function clearBufferedCommand() { |
776 | 783 | this[kBufferedCommandSymbol] = ''; |
777 | | - REPLServer.super_.prototype.multilineHistory.call(this); |
778 | 784 | }; |
779 | 785 |
|
780 | 786 | REPLServer.prototype.close = function close() { |
|