Skip to content

Commit 6532b3e

Browse files
committed
[completion] Remove extra trailing slash on directory completion
Fix junegunn#2931
1 parent c1c3551 commit 6532b3e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

shell/completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ __fzf_generic_path_completion() {
181181
[[ -z "$dir" ]] && dir='.'
182182
[[ "$dir" != "/" ]] && dir="${dir/%\//}"
183183
matches=$(eval "$1 $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS $2" __fzf_comprun "$4" -q "$leftover" | while read -r item; do
184-
printf "%q$3 " "$item"
184+
printf "%q " "${item%$3}$3"
185185
done)
186186
matches=${matches% }
187187
[[ -z "$3" ]] && [[ "$__fzf_nospace_commands" = *" ${COMP_WORDS[0]} "* ]] && matches="$matches "

shell/completion.zsh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ __fzf_generic_path_completion() {
146146
[ -z "$dir" ] && dir='.'
147147
[ "$dir" != "/" ] && dir="${dir/%\//}"
148148
matches=$(eval "$compgen $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS" __fzf_comprun "$cmd" ${(Q)${(Z+n+)fzf_opts}} -q "$leftover" | while read item; do
149-
echo -n "${(q)item}$suffix "
149+
item="${item%$suffix}$suffix"
150+
echo -n "${(q)item} "
150151
done)
151152
matches=${matches% }
152153
if [ -n "$matches" ]; then

0 commit comments

Comments
 (0)