nnn.c | 10 ++++++++-- diff --git a/nnn.c b/nnn.c index 402ee5820b54a9ac61b99e6cd200fc9d65c41812..588d582e8287391046f5b20736b58ebc3285ecb8 100644 --- a/nnn.c +++ b/nnn.c @@ -1050,7 +1050,7 @@ /* * Move non-matching entries to the end */ -static void +static int fill(struct entry **dents, int (*filter)(regex_t *, char *), regex_t *re) { static int count; @@ -1071,6 +1071,8 @@ continue; } } + + return ndents; } static int @@ -1082,8 +1084,10 @@ /* Search filter */ if (setfilter(&re, fltr) != 0) return -1; - fill(&dents, visible, &re); + ndents = fill(&dents, visible, &re); regfree(&re); + if (ndents == 0) + return 0; qsort(dents, ndents, sizeof(*dents), entrycmp); @@ -2224,6 +2228,8 @@ #endif ndents = dentfill(path, &dents, visible, &re); regfree(&re); + if (ndents == 0) + return 0; qsort(dents, ndents, sizeof(*dents), entrycmp);