summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2018-06-17 11:30:11 -0700
committerJohn Hawthorn <john@hawthorn.email>2018-06-17 11:48:50 -0700
commita0e259f93664a6ee8030da8f2b57027753793d3e (patch)
treebc188b56110716df60ceb5900089e3d4e2936ee6 /src
parent1b3306813c7afcb40cbe4da81e077151cae9ae91 (diff)
Initialize tty before reading choices
It's possible for user input to arrive while fzy was still reading choices from stdin. Previously, this would happen before the correct termios were set, causing fzy to misinterpret Enter as Ctrl-J for example. Fixes #81
Diffstat (limited to 'src')
-rw-r--r--src/fzy.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/fzy.c b/src/fzy.c
index 461f022..23f5673 100644
--- a/src/fzy.c
+++ b/src/fzy.c
@@ -20,16 +20,17 @@ int main(int argc, char *argv[]) {
choices_t choices;
choices_init(&choices, &options);
- choices_fread(&choices, stdin);
if (options.benchmark) {
if (!options.filter) {
fprintf(stderr, "Must specify -e/--show-matches with --benchmark\n");
exit(EXIT_FAILURE);
}
+ choices_fread(&choices, stdin);
for (int i = 0; i < options.benchmark; i++)
choices_search(&choices, options.filter);
} else if (options.filter) {
+ choices_fread(&choices, stdin);
choices_search(&choices, options.filter);
for (size_t i = 0; i < choices_available(&choices); i++) {
if (options.show_scores)
@@ -41,6 +42,8 @@ int main(int argc, char *argv[]) {
tty_t tty;
tty_init(&tty, options.tty_filename);
+ choices_fread(&choices, stdin);
+
if (options.num_lines > choices.size)
options.num_lines = choices.size;