This commit is contained in:
ridiculousfish 2012-08-15 18:20:44 -07:00
parent 26857fabdc
commit 7d029778e6
3 changed files with 37 additions and 10 deletions

View file

@ -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,

View file

@ -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

View file

@ -610,8 +610,10 @@ static void wildcard_completion_allocate( std::vector<completion_t> &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<completion_t> &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<completion_t> &outputs )
{
// PCA: not convinced this temporary variable is really necessary
std::vector<completion_t> 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;
}