From 4138689c19cde5ed0224266edd1804b73cd0b025 Mon Sep 17 00:00:00 2001 From: josuah Date: Sun, 20 Nov 2016 16:00:24 +0100 Subject: [PATCH] Fix selection of non-matching candidates --- TODO | 7 ++++--- input.c | 9 +++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index aa281b7..a8122f8 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,8 @@ - While the input fully match a candidate, make this candidate the - selected one + selected one. - Treat space as 'wildchars': every word is a query to run independently - and the matching words are those matching all the queries + and the matching words are those matching all the queries. - Use argv[token_*] for options like for ii irc client! \o/ @@ -10,4 +10,5 @@ - Improve the way to exit from the get_input loop. -- Add support for a default input string. +- Add support for a default input string (when I will need it or if + someone ask for it). diff --git a/input.c b/input.c index c7ec6af..001b895 100644 --- a/input.c +++ b/input.c @@ -28,6 +28,7 @@ input_get(Buffer *buffer, int tty_fd, Opt *opt) fclose(tty_fp); } + /* * Perform action associated with key */ @@ -90,8 +91,9 @@ input_key(char key, Buffer *buffer, Opt *opt) return TRUE; } + /* - * Set the current line to the next/previous/closest matching line. + * Set the current line to next/previous/any matching line. */ void action_jump(Buffer *buffer, int direction) @@ -100,7 +102,7 @@ action_jump(Buffer *buffer, int direction) if (direction == ANY && !buffer->current->matches) { line = matching_next(buffer->current); - line = matching_prev(buffer->current); + line = line ? line : matching_prev(buffer->current); } else if (direction == NEXT) { line = matching_next(line); } else if (direction == PREV) { @@ -110,6 +112,7 @@ action_jump(Buffer *buffer, int direction) buffer->current = line ? line : buffer->current; } + /* * Send the selection to stdout. */ @@ -129,6 +132,7 @@ action_print_selection(Buffer *buffer, Opt *opt) } } + /* * Remove the last word from the buffer's input */ @@ -146,6 +150,7 @@ action_remove_word_input(Buffer *buffer) buffer->input[i] = '\0'; } + /* * Add a character to the buffer input and filter lines again. */ -- 2.11.4.GIT