commit 4260a7bb84ed9ba515bdaad6618b28095dba01b3
parent f9460f1b2369c3dbe75e89c33bbdbc191b64a64b
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date: Tue, 24 Feb 2026 04:53:55 +0530
Enter dir exactly matching filter with `/`
Diffstat:
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/nnn.1 b/nnn.1
@@ -237,6 +237,7 @@ Special keys at filter prompt:
^char | Usual keybind functionality
Esc | Exit filter prompt but skip dir refresh
Alt+Esc | Unfilter, quit context
+ / | Enter dir exactly matching filter
-------- + ---------------------------------------
.Ed
.Pp
diff --git a/src/nnn.c b/src/nnn.c
@@ -3776,9 +3776,11 @@ static int filterentries(char *path, char *lastname)
} else if (len == REGEX_MAX - 1)
continue;
- wln[len] = (wchar_t)*ch;
- wln[++len] = '\0';
- wcstombs(ln, wln, REGEX_MAX);
+ if (*ch != FILTER) {
+ wln[len] = (wchar_t)*ch;
+ wln[++len] = '\0';
+ wcstombs(ln, wln, REGEX_MAX);
+ }
/* Forward-filtering optimization:
* - new matches can only be a subset of current matches.
@@ -3794,11 +3796,21 @@ static int filterentries(char *path, char *lastname)
continue;
}
- /* If the only match is a dir, auto-enter and cd into it */
- if ((ndents == 1) && cfg.autoenter && (pdents[0].flags & DIR_OR_DIRLNK)) {
- *ch = KEY_ENTER;
- cur = 0;
- goto end;
+ if (cfg.autoenter) {
+ /* If the only match is a dir, cd into it */
+ if ((ndents == 1) && (pdents[0].flags & DIR_OR_DIRLNK)) {
+ *ch = KEY_ENTER;
+ cur = 0;
+ goto end;
+ } else if ((*ch == FILTER) && *pln) {
+ /* If an exactly matching dir is present and filter key pressed, cd into it */
+ r = dentfind(pln, ndents);
+ if ((xstrcmp(pln, pdents[r].name) == 0) && (pdents[r].flags & DIR_OR_DIRLNK)) {
+ *ch = KEY_ENTER;
+ cur = r;
+ goto end;
+ }
+ }
}
/*