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
This commit is contained in:
Vladimir Beloborodov authored and Ben Noordhuis committed 2012-07-05 01:40:43 +02:00
1 parent 2ba96451a9
commit 3ea0397a1a
1 file changed
+7 -5
+7 -5
View File
@@ -188,12 +188,14 @@ Interface.prototype._onLine = function(line) {
Interface.prototype._addHistory = function() {
if (this.line.length === 0) return '';
this.history.unshift(this.line);
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();
}
this.historyIndex = -1;
// Only store so many
if (this.history.length > kHistorySize) this.history.pop();
return this.history[0];
};