fzy

terminal fuzzy finder picker

git clone https://9o.is/git/fzy.git

commit 6fba9f0d661e76b24a16b08857a17238884e2320
parent 422543b71e7b8a63e543030b9a7a736f0fa14975
Author: Jul <jul@9o.is>
Date:   Mon, 23 Feb 2026 22:46:53 +0800

fix width offset handling for printing "..."

Diffstat:
Msrc/tty_interface.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/tty_interface.c b/src/tty_interface.c @@ -34,6 +34,9 @@ static void draw_match(tty_interface_t *state, const char *choice, int selected) tty_t *tty = state->tty; options_t *options = state->options; char *search = state->last_search; + unsigned int width = tty_getwidth(tty); + unsigned int woffset = 3; + size_t len = strlen(choice); int n = strlen(search); size_t positions[MATCH_MAX_LEN]; @@ -59,7 +62,7 @@ static void draw_match(tty_interface_t *state, const char *choice, int selected) tty_setnowrap(tty); for (size_t i = 0, p = 0; choice[i] != '\0'; i++) { - if (i >= tty_getwidth(state->tty) - 5) { + if (i >= width - woffset && len > width) { tty_printf(tty, "..."); break; } @@ -77,6 +80,7 @@ static void draw_match(tty_interface_t *state, const char *choice, int selected) tty_putc(tty, ' '); } else if (choice[i] == '\t') { tty_printf(tty, " "); + woffset += 3; } else { tty_printf(tty, "%c", choice[i]); }