Skip to content

Commit

Permalink
Simplify logic used to determine when choices must be re-displayed
Browse files Browse the repository at this point in the history
Enabling dofilter implies dochoices by now. Therefore, there's no longer
necessary to fiddle with dochoices for each key binding that doesn't
result in filtering of the choices.
  • Loading branch information
mptre committed Dec 30, 2017
1 parent 494ce29 commit fe86c66
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions pick.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ selected_choice(void)
size_t choices_count = 0;
size_t selection = 0;
size_t yscroll = 0;
int dochoices = 1;
int dochoices = 0;
int dofilter = 1;
int query_grew = 0;

Expand Down Expand Up @@ -358,7 +358,6 @@ selected_choice(void)
tty_putp(cursor_normal, 0);
fflush(tty_out);

dochoices = 1;
switch (get_key(&buf)) {
case ENTER:
if (choices_count > 0)
Expand Down Expand Up @@ -455,11 +454,9 @@ selected_choice(void)
break;
case CTRL_A:
cursor_position = 0;
dochoices = 0;
break;
case CTRL_E:
cursor_position = query_length;
dochoices = 0;
break;
case LINE_DOWN:
if (selection < choices_count - 1) {
Expand All @@ -479,13 +476,11 @@ selected_choice(void)
while (cursor_position > 0
&& isu8cont(query[--cursor_position]))
continue;
dochoices = 0;
break;
case RIGHT:
while (cursor_position < query_length
&& isu8cont(query[++cursor_position]))
continue;
dochoices = 0;
break;
case PAGE_DOWN:
if (selection + choices_lines < choices_count)
Expand Down

0 comments on commit fe86c66

Please sign in to comment.