diff --git a/shell/completion.zsh b/shell/completion.zsh index 9537cc1..79a9b24 100644 --- a/shell/completion.zsh +++ b/shell/completion.zsh @@ -26,7 +26,8 @@ _fzf_path_completion() { leftover=${base/#"$dir"} leftover=${leftover/#\/} [ "$dir" = './' ] && dir='' - matches=$(\find -L ${~dir}* ${=find_opts} 2> /dev/null | ${=fzf} ${=FZF_COMPLETION_OPTS} ${=fzf_opts} -q "$leftover" | while read item; do + dir=${~dir} + matches=$(\find -L $dir* ${=find_opts} 2> /dev/null | ${=fzf} ${=FZF_COMPLETION_OPTS} ${=fzf_opts} -q "$leftover" | while read item; do printf "%q$suffix " "$item" done) matches=${matches% } @@ -37,7 +38,7 @@ _fzf_path_completion() { return fi dir=$(dirname "$dir") - [[ "$dir" =~ /$ ]] || dir="$dir"/ + dir=${dir%/}/ done } diff --git a/test/test_go.rb b/test/test_go.rb index 94e6a72..21299c4 100644 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -574,7 +574,7 @@ end module CompletionTest def test_file_completion - tmux.send_keys 'mkdir -p /tmp/fzf-test; touch /tmp/fzf-test/{1..100}', :Enter + tmux.send_keys 'mkdir -p /tmp/fzf-test; touch /tmp/fzf-test/{1..100}; touch ~/fzf-home', :Enter tmux.prepare tmux.send_keys 'cat /tmp/fzf-test/10**', :Tab, pane: 0 tmux.until(1) { |lines| lines.item_count > 0 } @@ -584,6 +584,18 @@ module CompletionTest lines[-1].include?('/tmp/fzf-test/10') && lines[-1].include?('/tmp/fzf-test/100') end + + # ~USERNAME** + tmux.send_keys 'C-u' + tmux.send_keys "cat ~#{ENV['USER']}**", :Tab, pane: 0 + tmux.until(1) { |lines| lines.item_count > 0 } + tmux.send_keys 'fzf-home' + tmux.until(1) { |lines| lines[-3].end_with? 'fzf-home' } + tmux.send_keys :Enter + tmux.until do |lines| + tmux.send_keys 'C-L' + lines[-1].include?('fzf-home') + end end def test_dir_completion