summaryrefslogtreecommitdiff
path: root/src/history.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/history.c')
-rw-r--r--src/history.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/history.c b/src/history.c
index bc6baa5..a04d580 100644
--- a/src/history.c
+++ b/src/history.c
@@ -228,6 +228,18 @@ history_add_upto (int history_id, const char *item, size_t max)
history_add_upto (hist_SHELLCMD, p, max);
}
+ if (defaults.history_compaction && max != INT_MAX) {
+ struct list_head *l;
+
+ for (l = h->head.prev ; l != &h->head ; l = l->prev) {
+ if (!strcmp (list_entry(l, struct history_item, node)->line, item)) {
+ list_del (l);
+ list_add_tail (l, &h->head);
+ return;
+ }
+ }
+ }
+
while (h->count >= max) {
list_first (i, &h->head, node);
if (!i) {