history: Stop saving non-consecutive duplicate entries

Whenever a command runs in the run dialog, it
will be added to the history unless it is
already the last entry. This does not apply
for entries that are not consecutive, which can
result in long chains of commands which
alternate, e.g. lg, r, lg, r, lg, r. Not only is
this wasteful in terms of space, but also
inconsistent with how history works elsewhere,
e.g. in the shell.

Therefore, remove entries in the history that are
equal to the one that will be added to the end of
of the history when the entry already exists.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/524
This commit is contained in:
Pascal Nowack 2018-09-22 17:43:22 +02:00
parent 4609cf1912
commit 2b1f664aed

View File

@ -76,6 +76,7 @@ var HistoryManager = new Lang.Class({
if (this._history.length == 0 ||
this._history[this._history.length - 1] != input) {
this._history = this._history.filter(entry => entry != input);
this._history.push(input);
this._save();
}