From f800cc14a8c1950a04af306b3774080fc782c0e9 Mon Sep 17 00:00:00 2001 From: codeliveroil Date: Mon, 20 Aug 2018 16:59:47 -0700 Subject: [PATCH] Fix backspace rendering and error handling. Fixes the following issues: - When in filter mode, hitting backspace on the first character renders the backspace character on the screen along with the first character instead of just the search prompt (i.e. '/'). For example, hitting backspace 3 times on the search string 'abc' produces this sequence: /abc /ab /a /a^? - Go to the 'end' label if matches() fails (via regcomp()) when hitting backspace. --- nnn.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nnn.c b/nnn.c index b7a970c9..3b5a326a 100644 --- a/nnn.c +++ b/nnn.c @@ -1077,8 +1077,13 @@ filterentries(char *path) wcstombs(ln, wln, REGEX_MAX); ndents = total; - if (matches(pln) == -1) - continue; + char *tmppln = pln; + if (strcmp(pln, "") == 0) { + tmppln=".*"; //otherwise setfilter will fail for the empty string. + } + if (matches(tmppln) == -1) { + goto end; + } redraw(path); printprompt(ln); continue;