diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 5b5a76dc3..2db059237 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -851,7 +851,7 @@ void wildcard_expander_t::expand_literal_intermediate_segment_with_fuzz(const wc void wildcard_expander_t::expand_last_segment(const wcstring &base_dir, DIR *base_dir_fp, const wcstring &wc, const wcstring &prefix) { wcstring name_str; - while (wreaddir(base_dir_fp, name_str)) { + while (!interrupted_or_overflowed() && wreaddir(base_dir_fp, name_str)) { if (flags & expand_flag::for_completions) { this->try_add_completion_result(base_dir + name_str, name_str, wc, prefix); } else { @@ -992,6 +992,13 @@ wildcard_result_t wildcard_expand_string(const wcstring &wc, const wcstring &wor return wildcard_result_t::no_match; } + // We do not support tab-completing recursive (**) wildcards. This is historic behavior. + // Do not descend any directories if there is a ** wildcard. + if (flags.get(expand_flag::for_completions) && + wc.find(ANY_STRING_RECURSIVE) != wcstring::npos) { + return wildcard_result_t::no_match; + } + // Compute the prefix and base dir. The prefix is what we prepend for filesystem operations // (i.e. the working directory), the base_dir is the part of the wildcard consumed thus far, // which we also have to append. The difference is that the base_dir is returned as part of the