diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-10-12 06:51:45 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-10-12 06:51:45 -0700 |
commit | 53be3cec4da34d00db66db7c0b600eb0044fe5cb (patch) | |
tree | 724d9bbc64508042cc9b388dbf615f2a5636a0f2 /linenoise | |
parent | 527518d6d425bdc6c2d30e65a7bc9ac99272e517 (diff) | |
download | txr-53be3cec4da34d00db66db7c0b600eb0044fe5cb.tar.gz txr-53be3cec4da34d00db66db7c0b600eb0044fe5cb.tar.bz2 txr-53be3cec4da34d00db66db7c0b600eb0044fe5cb.zip |
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.
Diffstat (limited to 'linenoise')
-rw-r--r-- | linenoise/linenoise.c | 6 |
1 files 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. */ |