diff --git a/complete.cpp b/complete.cpp index a4f6a9aaf..11d689c64 100644 --- a/complete.cpp +++ b/complete.cpp @@ -1521,8 +1521,9 @@ void completer_t::complete_param_expand( const wcstring &sstr, bool do_file) if (! do_file) flags |= EXPAND_SKIP_WILDCARDS; - - if (type == COMPLETE_AUTOSUGGEST) + + /* Squelch file descriptions per issue 254 */ + if (type == COMPLETE_AUTOSUGGEST || do_file) flags |= EXPAND_NO_DESCRIPTIONS; if( expand_string( comp_str, diff --git a/share/functions/__fish_complete_cd.fish b/share/functions/__fish_complete_cd.fish index 73307e5ee..cb10b7cf3 100644 --- a/share/functions/__fish_complete_cd.fish +++ b/share/functions/__fish_complete_cd.fish @@ -1,3 +1,8 @@ +function __fish_complete_cd -d "Completions for the cd command" + false +end + + function __fish_complete_cd -d "Completions for the cd command" # # We can't simply use __fish_complete_directories because of the CDPATH @@ -13,11 +18,15 @@ function __fish_complete_cd -d "Completions for the cd command" else set mycdpath $CDPATH end + + # Note how this works: we evaluate $ctoken*/ + # That trailing slash ensures that we only expand directories set -l ctoken (commandline -ct) if echo $ctoken | sgrep '^/\|^\./\|^\.\./\|^~/' >/dev/null # This is an absolute search path - eval printf '\%s\\tDirectory\\n' $ctoken\*/ + # Squelch descriptions per issue 254 + eval printf '\%s\\n' $ctoken\*/ else # This is a relative search path # Iterate over every directory in CDPATH @@ -30,7 +39,14 @@ function __fish_complete_cd -d "Completions for the cd command" builtin cd $wd eval builtin cd $i - eval printf '"%s\tDirectory in "'$i'"\n"' $ctoken\*/ + # What we would really like to do is skip descriptions if all + # valid paths are in the same directory, but we don't know how to + # do that yet; so instead skip descriptions if CDPATH is just . + if test "$mycdpath" = . + eval printf '"%s\n"' $ctoken\*/ + else + eval printf '"%s\tin "'$i'"\n"' $ctoken\*/ + end end end diff --git a/wildcard.cpp b/wildcard.cpp index e3f348a50..5a87eeb27 100644 --- a/wildcard.cpp +++ b/wildcard.cpp @@ -610,8 +610,10 @@ static void wildcard_completion_allocate( std::vector &list, } } + + bool wants_desc = ! (expand_flags & EXPAND_NO_DESCRIPTIONS); wcstring desc; - if (! (expand_flags & EXPAND_NO_DESCRIPTIONS)) + if (wants_desc) desc = file_get_desc( fullname.c_str(), lstat_res, lbuf, stat_res, buf, stat_errno ); if( sz >= 0 && S_ISDIR(buf.st_mode) ) @@ -619,13 +621,20 @@ static void wildcard_completion_allocate( std::vector &list, flags = flags | COMPLETE_NO_SPACE; munged_completion = completion; munged_completion.push_back(L'/'); - sb.append(desc); + if (wants_desc) + sb.append(desc); } else { - sb.append(desc); - sb.append(L", "); - sb.append(format_size(sz)); + if (wants_desc) + { + if (! desc.empty()) + { + sb.append(desc); + sb.append(L", "); + } + sb.append(format_size(sz)); + } } const wcstring &completion_to_use = munged_completion.empty() ? completion : munged_completion; @@ -1089,8 +1098,9 @@ int wildcard_expand( const wchar_t *wc, int wildcard_expand_string(const wcstring &wc, const wcstring &base_dir, expand_flags_t flags, std::vector &outputs ) { + // PCA: not convinced this temporary variable is really necessary std::vector lst; - int res = wildcard_expand(wc.c_str(), base_dir.c_str(), flags, lst); + int res = wildcard_expand(wc.c_str(), base_dir.c_str(), flags, lst); outputs.insert(outputs.end(), lst.begin(), lst.end()); return res; }