Fix #135 - Directory completion to append /

This commit is contained in:
Junegunn Choi 2015-03-04 12:59:23 +09:00
parent d4b41c5e03
commit 79c147ed78
2 changed files with 9 additions and 6 deletions

View File

@ -88,7 +88,7 @@ _fzf_path_completion() {
[ "$dir" = './' ] && dir='' [ "$dir" = './' ] && dir=''
tput sc tput sc
matches=$(find -L "$dir"* $1 2> /dev/null | fzf $FZF_COMPLETION_OPTS $2 -q "$leftover" | while read item; do matches=$(find -L "$dir"* $1 2> /dev/null | fzf $FZF_COMPLETION_OPTS $2 -q "$leftover" | while read item; do
printf '%q ' "$item" printf "%q$3 " "$item"
done) done)
matches=${matches% } matches=${matches% }
if [ -n "$matches" ]; then if [ -n "$matches" ]; then
@ -103,6 +103,7 @@ _fzf_path_completion() {
[[ "$dir" =~ /$ ]] || dir="$dir"/ [[ "$dir" =~ /$ ]] || dir="$dir"/
done done
else else
shift
shift shift
shift shift
_fzf_handle_dynamic_completion "$cmd" "$@" _fzf_handle_dynamic_completion "$cmd" "$@"
@ -136,19 +137,19 @@ _fzf_list_completion() {
_fzf_all_completion() { _fzf_all_completion() {
_fzf_path_completion \ _fzf_path_completion \
"-name .git -prune -o -name .svn -prune -o -type d -print -o -type f -print -o -type l -print" \ "-name .git -prune -o -name .svn -prune -o -type d -print -o -type f -print -o -type l -print" \
"-m" "$@" "-m" "" "$@"
} }
_fzf_file_completion() { _fzf_file_completion() {
_fzf_path_completion \ _fzf_path_completion \
"-name .git -prune -o -name .svn -prune -o -type f -print -o -type l -print" \ "-name .git -prune -o -name .svn -prune -o -type f -print -o -type l -print" \
"-m" "$@" "-m" "" "$@"
} }
_fzf_dir_completion() { _fzf_dir_completion() {
_fzf_path_completion \ _fzf_path_completion \
"-name .git -prune -o -name .svn -prune -o -type d -print" \ "-name .git -prune -o -name .svn -prune -o -type d -print" \
"" "$@" "" "/" "$@"
} }
_fzf_kill_completion() { _fzf_kill_completion() {
@ -219,7 +220,7 @@ fi
# Directory # Directory
for cmd in $d_cmds; do for cmd in $d_cmds; do
complete -F _fzf_dir_completion -o default -o bashdefault $cmd complete -F _fzf_dir_completion -o nospace -o default -o bashdefault $cmd
done done
# File # File

View File

@ -517,7 +517,9 @@ class TestBash < TestBase
tmux.send_keys 55 tmux.send_keys 55
tmux.until { |lines| lines[-2].start_with? ' 1/' } tmux.until { |lines| lines[-2].start_with? ' 1/' }
tmux.send_keys :Enter tmux.send_keys :Enter
tmux.until { |lines| lines[-1] == 'cd /tmp/fzf-test/d55' } tmux.until { |lines| lines[-1] == 'cd /tmp/fzf-test/d55/' }
tmux.send_keys :xx
tmux.until { |lines| lines[-1] == 'cd /tmp/fzf-test/d55/xx' }
end end
def test_process_completion def test_process_completion