mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 14:01:20 -03:00
Don't include child directories of $PATH in completions
Directories are completed like commands, because of implicit cd. However, directories found inside $PATH entries should not be completed, as implicit cd doesn't work there. Similarly, directories should not be completed after the `command` builtin. Fixes #1695.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# vim: set filetype=fish:
|
||||
|
||||
# Test that conditions that add or remove completions don't deadlock, etc.
|
||||
# We actually encountered some case that was effectively like this (Issue 2 in github)
|
||||
@@ -43,3 +44,31 @@ complete -C'CCCC -' | sort
|
||||
complete -c CCCC -e
|
||||
echo "CCCC:"
|
||||
complete -C'CCCC -' | sort
|
||||
|
||||
# Test that directory completions work correctly
|
||||
if begin; rm -rf test6.tmp.dir; and mkdir test6.tmp.dir; end
|
||||
pushd test6.tmp.dir
|
||||
set -l dir (mktemp -d XXXXXXXX)
|
||||
if complete -C$dir | grep "^$dir/.*Directory" >/dev/null
|
||||
echo "implicit cd complete works"
|
||||
else
|
||||
echo "no implicit cd complete"
|
||||
end
|
||||
if complete -C"command $dir" | grep "^$dir/.*Directory" >/dev/null
|
||||
echo "implicit cd complete incorrect after 'command'"
|
||||
else
|
||||
echo "no implicit cd complete after 'command'"
|
||||
end
|
||||
popd
|
||||
if begin
|
||||
set -l PATH $PWD/test6.tmp.dir $PATH
|
||||
complete -C$dir | grep "^$dir/.*Directory" >/dev/null
|
||||
end
|
||||
echo "incorrect implicit cd from PATH"
|
||||
else
|
||||
echo "PATH does not cause incorrect implicit cd"
|
||||
end
|
||||
rm -rf test6.tmp.dir
|
||||
else
|
||||
echo "error: could not create temp environment" >&2
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user