Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repl: revert multiline history #24804

Closed
wants to merge 2 commits into from
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
25 changes: 0 additions & 25 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ function Interface(input, output, completer, terminal) {

// Current line
this.line = '';
this.multiline = '';

this._setRawMode(true);
this.terminal = true;
Expand Down Expand Up @@ -337,7 +336,6 @@ Interface.prototype._addHistory = function() {
if (dupIndex !== -1) this.history.splice(dupIndex, 1);
}

this.multiline += this.line;
this.history.unshift(this.line);

// Only store so many
Expand All @@ -348,29 +346,6 @@ Interface.prototype._addHistory = function() {
return this.history[0];
};

// Called when a multiline is seen by the repl
Interface.prototype.undoHistory = function() {
if (this.terminal) {
this.history.shift();
}
};

// 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) {
const dupIndex = this.history.indexOf(this.multiline);
if (dupIndex !== -1) this.history.splice(dupIndex, 1);
// Remove the last entered line as multiline
// already contains them.
this.history.shift();
this.history.unshift(this.multiline);
}

// clear the multiline buffer
this.multiline = '';
};

Interface.prototype._refreshLine = function() {
// line length
Expand Down
8 changes: 0 additions & 8 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,13 +666,6 @@ function REPLServer(prompt,
}
}

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

// Clear buffer if no SyntaxErrors
self.clearBufferedCommand();
sawCtrlD = false;
Expand Down Expand Up @@ -895,7 +888,6 @@ REPLServer.prototype.displayPrompt = function(preserveCursor) {
const len = this.lines.level.length ? this.lines.level.length - 1 : 0;
const levelInd = '..'.repeat(len);
prompt += levelInd + ' ';
Interface.prototype.undoHistory.call(this);
}

// Do not overwrite `_initialPrompt` here
Expand Down
7 changes: 0 additions & 7 deletions test/parallel/test-repl-persistent-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,6 @@ const tests = [
test: [UP],
expected: [prompt, replFailedRead, prompt, replDisabled, prompt]
},
{ // Tests multiline history
env: {},
test: ['{', '}', UP, CLEAR],
expected: [prompt, '{', '... ', '}', '{}\n',
prompt, `${prompt}{}`, prompt],
clean: false
},
{
before: function before() {
if (common.isWindows) {
Expand Down