From 95d5e55df25962282b3a9522400db0f4f227b413 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 14 Sep 2013 23:59:53 -0700 Subject: [PATCH] Don't do fuzzy matching for file completions for arguments beginning with a dash, as suggested in #568 --- complete.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/complete.cpp b/complete.cpp index ad2bbb143..7b0b41735 100644 --- a/complete.cpp +++ b/complete.cpp @@ -1616,7 +1616,7 @@ void completer_t::complete_param_expand(const wcstring &sstr, bool do_file) comp_str = str; } - expand_flags_t flags = EXPAND_SKIP_CMDSUBST | ACCEPT_INCOMPLETE; + expand_flags_t flags = EXPAND_SKIP_CMDSUBST | ACCEPT_INCOMPLETE | this->expand_flags(); if (! do_file) flags |= EXPAND_SKIP_WILDCARDS; @@ -1625,9 +1625,13 @@ void completer_t::complete_param_expand(const wcstring &sstr, bool do_file) if (this->type() == COMPLETE_AUTOSUGGEST || do_file) flags |= EXPAND_NO_DESCRIPTIONS; + /* Don't do fuzzy matching for files if the string begins with a dash (#568). We could consider relaxing this if there was a preceding double-dash argument */ + if (string_prefixes_string(L"-", sstr)) + flags &= ~EXPAND_FUZZY_MATCH; + if (expand_string(comp_str, this->completions, - flags | this->expand_flags()) == EXPAND_ERROR) + flags ) == EXPAND_ERROR) { debug(3, L"Error while expanding string '%ls'", comp_str); }