From: Arun Prakash Jana Date: Sat, 29 Apr 2023 16:13:29 +0000 (+0530) Subject: Filter adjustment when opening context from plugin X-Git-Tag: v4.9~25 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=5d81aeb4776758e1b0e6bc47acdd93dc5e2535b5;p=nnn.git Filter adjustment when opening context from plugin - Clear filter only when a plugin is selected manually. Plugin dir should be unfiltered when opened. - Plugins invoked by keys don't require clearing filter of original context. If a new context is opened using the plugin, it will be unfiltered by default. If the same context is re-used (when all the contexts are in use) the filter should be cleared so the the new path is opened unfiltered. --- diff --git a/src/nnn.c b/src/nnn.c index d2c262a5..46e95c5f 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -2992,7 +2992,7 @@ static int (*filterfn)(const fltrexp_t *fltr, const char *fname) = &visible_str; static void clearfilter(void) { - char *fltr = g_ctx[cfg.curctx].c_fltr; + char * const fltr = g_ctx[cfg.curctx].c_fltr; if (fltr[1]) { fltr[REGEX_MAX - 1] = fltr[1]; @@ -4455,6 +4455,7 @@ static void set_smart_ctx(int ctx, char *nextpath, char **path, char *file, char ctx = (int)(get_free_ctx() + 1); if (ctx == 0 || ctx == cfg.curctx + 1) { /* Same context */ + clearfilter(); xstrsncpy(*lastdir, *path, PATH_MAX); xstrsncpy(*path, nextpath, PATH_MAX); } else { /* New context */ @@ -7898,9 +7899,9 @@ nochange: xstrsncpy(runfile, pdents[cur].name, NAME_MAX); g_state.runctx = cfg.curctx; lastname[0] = '\0'; + clearfilter(); } setdirwatch(); - clearfilter(); if (g_state.runplugin == 1) /* Allow filtering in plugins directory */ presel = FILTER; goto begin;