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. 4
      lib/readline.js

4
lib/readline.js

@ -188,12 +188,14 @@ Interface.prototype._onLine = function(line) {
Interface.prototype._addHistory = function() { Interface.prototype._addHistory = function() {
if (this.line.length === 0) return ''; if (this.line.length === 0) return '';
if (this.history.length === 0 || this.history[0] !== this.line) {
this.history.unshift(this.line); this.history.unshift(this.line);
this.historyIndex = -1;
// Only store so many // Only store so many
if (this.history.length > kHistorySize) this.history.pop(); if (this.history.length > kHistorySize) this.history.pop();
}
this.historyIndex = -1;
return this.history[0]; return this.history[0];
}; };

Loading…
Cancel
Save