summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-03-04 12:59:23 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-03-04 12:59:23 +0900
commit79c147ed783dab85b03eeb8f5f1458b20c5d6315 (patch)
tree6503eedfe2d1867b778fd3bf17339b39da4b504f
parentd4b41c5e035b119e47fbdec7afb16ef14545151e (diff)
Fix #135 - Directory completion to append /
-rw-r--r--fzf-completion.bash11
-rw-r--r--test/test_go.rb4
2 files changed, 9 insertions, 6 deletions
diff --git a/fzf-completion.bash b/fzf-completion.bash
index 61797b1c..b90206c6 100644
--- a/fzf-completion.bash
+++ b/fzf-completion.bash
@@ -88,7 +88,7 @@ _fzf_path_completion() {
[ "$dir" = './' ] && dir=''
tput sc
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)
matches=${matches% }
if [ -n "$matches" ]; then
@@ -105,6 +105,7 @@ _fzf_path_completion() {
else
shift
shift
+ shift
_fzf_handle_dynamic_completion "$cmd" "$@"
fi
}
@@ -136,19 +137,19 @@ _fzf_list_completion() {
_fzf_all_completion() {
_fzf_path_completion \
"-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_path_completion \
"-name .git -prune -o -name .svn -prune -o -type f -print -o -type l -print" \
- "-m" "$@"
+ "-m" "" "$@"
}
_fzf_dir_completion() {
_fzf_path_completion \
"-name .git -prune -o -name .svn -prune -o -type d -print" \
- "" "$@"
+ "" "/" "$@"
}
_fzf_kill_completion() {
@@ -219,7 +220,7 @@ fi
# Directory
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
# File
diff --git a/test/test_go.rb b/test/test_go.rb
index 6aa438b0..680edd67 100644
--- a/test/test_go.rb
+++ b/test/test_go.rb
@@ -517,7 +517,9 @@ class TestBash < TestBase
tmux.send_keys 55
tmux.until { |lines| lines[-2].start_with? ' 1/' }
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
def test_process_completion