From b86cf006f1ac16982a30c95f8f4c6c794ec94e48 Mon Sep 17 00:00:00 2001 From: josuah Date: Sun, 20 Nov 2016 18:01:29 +0100 Subject: [PATCH] Managing no candidate that match --- buffer.c | 2 +- draw.c | 3 ++- input.c | 16 +++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/buffer.c b/buffer.c index 27815c9..567adff 100644 --- a/buffer.c +++ b/buffer.c @@ -168,7 +168,7 @@ int line_match_input(Line *line, char *input, Opt *opt) { return (opt->complete && !strncmp(input, line->content, strlen(input))) - || strstr(line->content, input) + || (!opt->complete && strstr(line->content, input)) || line->header ? TRUE : FALSE; } diff --git a/draw.c b/draw.c index 1ee25eb..c4b701c 100644 --- a/draw.c +++ b/draw.c @@ -40,6 +40,7 @@ draw_line(Line *line, int current, int cols, Opt *opt) /* shift without overflowing terminal width */ if (!line->header && line->comment[0] != '\0') { + /* MAX with '1' as \033[0C still move 1 to the right */ fprintf(stderr, "\033[%dC", MAX(40 - n, 1)); n += MAX(40 - n, 1); } @@ -165,7 +166,7 @@ draw_prompt(Buffer *buffer, int cols, Opt *opt) fputs("\033[1;30m", stderr); /* suggest without overflowing terminal width */ - if (opt->complete) { + if (opt->complete && buffer->matching > 0) { for (; i < strlen(suggest) && cols > 0; cols--, i++) fputc(suggest[i], stderr); } diff --git a/input.c b/input.c index cb59675..ef2bae3 100644 --- a/input.c +++ b/input.c @@ -121,13 +121,15 @@ action_print_selection(Buffer *buffer, Opt *opt) { fputs("\r\033[K", stderr); - if (opt->print_number) { - printf("%d\n", buffer->current->number); - } else { - if (opt->complete) { - puts(buffer->input); - } else { - puts(buffer->current->content); + if (buffer->matching > 0) { + if (opt->print_number) { + printf("%d\n", buffer->current->number); + } else { + if (opt->complete) { + puts(buffer->input); + } else { + puts(buffer->current->content); + } } } } -- 2.11.4.GIT