diff options
author | Michael Vetter <jubalh@iodoru.org> | 2023-04-18 09:38:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-18 09:38:12 +0200 |
commit | f51dc019bc08e41fa4564d465136522648a7a663 (patch) | |
tree | a68384faef2d8a28b46da63e4dfc8998b83eee1e /src/ui | |
parent | 1b679498b6818eb433cdaa1361f18e00ad1860fc (diff) | |
parent | 59b99fece8ffa10c6a23b11111b7b49858ea9139 (diff) | |
download | profani-tty-f51dc019bc08e41fa4564d465136522648a7a663.tar.gz |
Merge pull request #1829 from H3rnand3zzz/fix/readline-history
Don't add the same command twice to history
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/inputwin.c | 13 |
1 files changed, 8 insertions, 5 deletions
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; |