diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-13 07:15:22 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-13 07:15:22 -0700 |
commit | e8bfdef6d901431c1d69ef4d70a26451dca6e084 (patch) | |
tree | 903ef8ca063f58557c968c3aeb6a58509f828293 /linenoise | |
parent | 0c1bd0da13ec070f52f3144b50868fb4153471e5 (diff) | |
download | txr-e8bfdef6d901431c1d69ef4d70a26451dca6e084.tar.gz txr-e8bfdef6d901431c1d69ef4d70a26451dca6e084.tar.bz2 txr-e8bfdef6d901431c1d69ef4d70a26451dca6e084.zip |
linenoise: suppress duplicates in Ctrl-R search.
* linenoise/linenoise.c (history_search):
Don't step through identical lines, which
looks as if Ctrl-R is being ignored.
Diffstat (limited to 'linenoise')
-rw-r--r-- | linenoise/linenoise.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 5af71ed0..44f88211 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -473,8 +473,14 @@ static int history_search(lino_t *l) } { - int ni = next_hist_match(l, hpat, hp, &dp); - + int ni, sp = hp; + + do { + ni = next_hist_match(l, hpat, sp, &dp); + sp = ni - 1; + } while (ni >= 0 && hi < l->history_len && + ni != hi && + strcmp(l->history[hi], l->history[ni]) == 0); if (ni < 0) break; |