Browse Source

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
v0.9.1-release
Vladimir Beloborodov 13 years ago
committed by Ben Noordhuis
parent
commit
3ea0397a1a
  1. 10
      lib/readline.js

10
lib/readline.js

@ -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];
};

Loading…
Cancel
Save