summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tty_interface.c22
-rw-r--r--test/acceptance/acceptance_test.rb12
2 files changed, 20 insertions, 14 deletions
diff --git a/src/tty_interface.c b/src/tty_interface.c
index a76cfa9..746da4d 100644
--- a/src/tty_interface.c
+++ b/src/tty_interface.c
@@ -42,15 +42,12 @@ static void draw_match(tty_interface_t *state, const char *choice, int selected)
score_t score = match_positions(search, choice, &positions[0]);
- size_t maxwidth = tty_getwidth(tty);
-
- if (options->show_scores && maxwidth >= 9) {
+ if (options->show_scores) {
if (score == SCORE_MIN) {
tty_printf(tty, "( ) ");
} else {
tty_printf(tty, "(%5.2f) ", score);
}
- maxwidth -= 8;
}
if (selected)
@@ -60,20 +57,17 @@ static void draw_match(tty_interface_t *state, const char *choice, int selected)
tty_setinvert(tty);
#endif
+ tty_setnowrap(tty);
for (size_t i = 0, p = 0; choice[i] != '\0'; i++) {
- if (i + 1 < maxwidth) {
- if (positions[p] == i) {
- tty_setfg(tty, TTY_COLOR_HIGHLIGHT);
- p++;
- } else {
- tty_setfg(tty, TTY_COLOR_NORMAL);
- }
- tty_printf(tty, "%c", choice[i]);
+ if (positions[p] == i) {
+ tty_setfg(tty, TTY_COLOR_HIGHLIGHT);
+ p++;
} else {
- tty_printf(tty, "$");
- break;
+ tty_setfg(tty, TTY_COLOR_NORMAL);
}
+ tty_printf(tty, "%c", choice[i]);
}
+ tty_setwrap(tty);
tty_setnormal(tty);
}
diff --git a/test/acceptance/acceptance_test.rb b/test/acceptance/acceptance_test.rb
index 6123b2d..6ab8b34 100644
--- a/test/acceptance/acceptance_test.rb
+++ b/test/acceptance/acceptance_test.rb
@@ -430,6 +430,18 @@ class FzyTest < Minitest::Test
@tty.assert_cursor_position(y: 0, x: 8)
end
+ def test_long_strings
+ ascii = "LongStringOfText" * 6
+ unicode = "LongStringOfText" * 3
+
+ @tty = interactive_fzy(input: [ascii, unicode])
+ @tty.assert_matches <<~TTY
+ >
+ LongStringOfTextLongStringOfTextLongStringOfTextLongStringOfTextLongStringOfText
+ LongStringOfTextLongStringOfTextLongStri
+ TTY
+ end
+
def test_help
@tty = TTYtest.new_terminal(%{#{FZY_PATH} --help})
@tty.assert_matches <<TTY