From 352dee2a8251a2d02a689e03aeea423bd948e271 Mon Sep 17 00:00:00 2001 From: Anton Lindqvist Date: Sat, 30 Dec 2017 19:04:46 +0100 Subject: [PATCH] fixup! Ensure correctness while typing a query fast --- pick.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pick.c b/pick.c index 92513821..fbbb3b77 100644 --- a/pick.c +++ b/pick.c @@ -71,7 +71,7 @@ struct choice { static int choicecmp(const void *, const void *); static void delete_between(char *, size_t, size_t, size_t); static char *eager_strpbrk(const char *, const char *); -static int filter_choices(size_t, int); +static int filter_choices(size_t); static char *get_choices(void); static enum key get_key(const char **); static void handle_sigwinch(int); @@ -325,11 +325,12 @@ selected_choice(void) choices_count = choices.length; query_grew = 0; if (dofilter) { - dofilter = 0; - if (filter_choices(choices_count, query_length > 0)) - selection = yscroll = 0; - else + if (filter_choices(choices_count)) { + dofilter = selection = yscroll = 0; + dochoices = 1; + } else { dochoices = 0; + } } tty_putp(cursor_invisible, 0); @@ -533,14 +534,13 @@ selected_choice(void) } /* - * Filter the first nchoices number of choices using the current query. - * If intr is non-zero, regularly check for new user input and abort the - * filtering. This improves the performance when the cardinality of the choices - * is large. + * Filter the first nchoices number of choices using the current query and + * regularly check for new user input and abort the filtering. This improves the + * performance when the cardinality of the choices is large. * Returns non-zero if the filtering was not aborted. */ int -filter_choices(size_t nchoices, int intr) +filter_choices(size_t nchoices) { struct choice *c; struct pollfd pfd; @@ -560,7 +560,7 @@ filter_choices(size_t nchoices, int intr) c->score = (double)query_length/match_length/c->length; } - if (intr && i > 0 && i % 50 == 0) { + if (i > 0 && i % 50 == 0) { pfd.fd = fileno(tty_in); pfd.events = POLLIN; if ((nready = poll(&pfd, 1, 0)) == -1)