From aeaacedf75a99b06a93d8fe873ed7a795ed4f3dd Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 3 Oct 2015 15:44:57 -0700 Subject: Don't do intermediate fuzzy directory matching with $PATH When expanding an executable with $PATH, don't attempt to interpret the directories in PATH as fuzzy matching. Fixes #2413. --- src/wildcard.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/wildcard.cpp') diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 45d3cb6a..54c90e98 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -1002,9 +1002,11 @@ void wildcard_expander_t::expand(const wcstring &base_dir, const wchar_t *wc) /* This just trumps everything */ size_t before = this->resolved_completions->size(); this->expand(base_dir + wc_segment + L'/', wc_remainder); - if ((this->flags & EXPAND_FUZZY_MATCH) && this->resolved_completions->size() == before) + + /* Maybe try a fuzzy match (#94) if nothing was found with the literal match. Respect EXPAND_NO_DIRECTORY_ABBREVIATIONS (#2413). */ + bool allow_fuzzy = (this->flags & (EXPAND_FUZZY_MATCH | EXPAND_NO_FUZZY_DIRECTORIES)) == EXPAND_FUZZY_MATCH; + if (allow_fuzzy && this->resolved_completions->size() == before) { - /* Nothing was found with the literal match. Try a fuzzy match (#94). */ assert(this->flags & EXPAND_FOR_COMPLETIONS); DIR *base_dir_fd = open_dir(base_dir); if (base_dir_fd != NULL) -- cgit v1.2.3