nnn

mirror of https://github.com/jarun/nnn
Log | Files | Refs | README | LICENSE

commit 768e3c54979b5d81430b6392475cd9438058812a
parent 683f4b04364758431f8a65873c1621b2bffab568
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date:   Thu,  5 Feb 2026 22:29:20 +0530

Treat space, underscore and hyphen as same in fuzzy filters

Diffstat:
Msrc/nnn.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/nnn.c b/src/nnn.c @@ -3076,6 +3076,14 @@ static int setfilter(regex_t *regex, const char *filter) } #endif +/* Normalize space, underscore, and hyphen to the same character for fuzzy matching */ +static inline wchar_t normalize_char(wchar_t c) +{ + if (c == L' ' || c == L'_' || c == L'-') + return L' '; + return c; +} + /* * Fuzzy match: check if all characters in filter appear in order in fname * Case-sensitivity is controlled by fnstrstr function pointer @@ -3115,7 +3123,7 @@ static int fuzzy_match(const char *filter, const char *fname) /* Match characters in order */ while (*f && *n) { - if (*f == *n) + if (normalize_char(*f) == normalize_char(*n)) ++f; ++n; }