Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
readline: Use one history item for reentered line
If the command entered is exactly the same as the last history item,
don't dupe it in the history
  • Loading branch information
Vladimir Beloborodov authored and bnoordhuis committed Jul 4, 2012
1 parent 2ba9645 commit 3ea0397
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/readline.js
Expand Up @@ -188,12 +188,14 @@ Interface.prototype._onLine = function(line) {
Interface.prototype._addHistory = function() {
if (this.line.length === 0) return '';

this.history.unshift(this.line);
this.historyIndex = -1;
if (this.history.length === 0 || this.history[0] !== this.line) {
this.history.unshift(this.line);

// Only store so many
if (this.history.length > kHistorySize) this.history.pop();
// Only store so many
if (this.history.length > kHistorySize) this.history.pop();
}

this.historyIndex = -1;
return this.history[0];
};

Expand Down

0 comments on commit 3ea0397

Please sign in to comment.