From 59b99fece8ffa10c6a23b11111b7b49858ea9139 Mon Sep 17 00:00:00 2001 From: John Hernandez <129467592+H3rnand3zzz@users.noreply.github.com> Date: Fri, 14 Apr 2023 20:57:20 +0200 Subject: Don't add the same command twice to history Expected behaviour When you type /command /command it should be just 1 entry in the history. Behaviour All the entries were saved. Behaviour is changed by introducing check. Before adding to history, entry now is compared to the last history entry. --- src/ui/inputwin.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index e59be8b5..453dfeac 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -568,12 +568,15 @@ _inp_rl_startup_hook(void) static void _inp_rl_linehandler(char* line) { - if (line && *line) { - if (!get_password) { - add_history(line); - } - } inp_line = line; + if (!line || !*line || get_password) { + return; + } + HISTORY_STATE* history = history_get_history_state(); + HIST_ENTRY* last = history->length > 0 ? history->entries[history->length - 1] : NULL; + if (last == NULL || strcmp(last->line, line) != 0) { + add_history(line); + } } static gboolean shift_tab = FALSE; -- cgit 1.4.1-2-gfad0