From 53be3cec4da34d00db66db7c0b600eb0044fe5cb Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 12 Oct 2016 06:51:45 -0700 Subject: linenoise: bug in resubmit historic line when dupe. When Ctrl-X Enter is used to resubmit a line from the history, and it is a duplicate, it is not entered into the history. The position then doesn't advance to the next historic line. * linenoise/linenoise.c (lino_hist_add): Do add the line even if it is duplicate if the last submitted line was from the middle of the history. --- linenoise/linenoise.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 7e78adf9..78949cc8 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -2359,8 +2359,10 @@ int lino_hist_add(lino_t *ls, const char *line) { memset(ls->history, 0, size); } - /* Don't add duplicated lines. */ - if (ls->history_len && !strcmp(ls->history[ls->history_len-1], line)) return 0; + /* Don't add duplicated lines, unless we are resubmitting historic lines. */ + if (ls->history_len && !ls->save_hist_idx && + !strcmp(ls->history[ls->history_len-1], line)) + return 0; /* Add an heap allocated copy of the line in the history. * If we reached the max length, remove the older line. */ -- cgit v1.2.3