fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
commit c6783048dc7fac6dcc5b299017b35c475df311f8 parent ff5ebc116d4da84b5fbe53e7311f11d2be153c61 Author: momotaro <momotaro.n@gmail.com> Date: Wed, 21 Dec 2016 04:18:05 +0900 Fix a problem that the cursor position shifted upward Diffstat:
| M | src/tty_interface.c | | | 9 | ++++++--- |
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/tty_interface.c b/src/tty_interface.c @@ -72,8 +72,9 @@ static void draw(tty_interface_t *state) { size_t current_selection = choices->selection; if (current_selection + options->scrolloff >= num_lines) { start = current_selection + options->scrolloff - num_lines + 1; - if (start + num_lines >= choices_available(choices)) { - start = choices_available(choices) - num_lines; + size_t available = choices_available(choices); + if (start + num_lines >= available && available > 0) { + start = available - num_lines; } } tty_setcol(tty, 0); @@ -87,7 +88,9 @@ static void draw(tty_interface_t *state) { draw_match(state, choice, i == choices->selection); } } - tty_moveup(tty, num_lines); + if (num_lines > 0) { + tty_moveup(tty, num_lines); + } tty_setcol(tty, strlen(options->prompt) + strlen(state->search)); tty_flush(tty); }