mirror of
https://github.com/junegunn/fzf
synced 2024-10-30 09:20:14 +00:00
[zsh-completion] Temporarily set nonomatch (#230)
No error on ~INVALID_USERNAME**<TAB>
This commit is contained in:
parent
26a141c6a6
commit
207aa07891
@ -11,7 +11,7 @@
|
|||||||
# - $FZF_COMPLETION_OPTS (default: empty)
|
# - $FZF_COMPLETION_OPTS (default: empty)
|
||||||
|
|
||||||
_fzf_path_completion() {
|
_fzf_path_completion() {
|
||||||
local base lbuf find_opts fzf_opts suffix tail fzf dir leftover matches
|
local base lbuf find_opts fzf_opts suffix tail fzf dir leftover matches nnm
|
||||||
base=$1
|
base=$1
|
||||||
lbuf=$2
|
lbuf=$2
|
||||||
find_opts=$3
|
find_opts=$3
|
||||||
@ -20,6 +20,10 @@ _fzf_path_completion() {
|
|||||||
tail=$6
|
tail=$6
|
||||||
[ ${FZF_TMUX:-1} -eq 1 ] && fzf="fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%}" || fzf="fzf"
|
[ ${FZF_TMUX:-1} -eq 1 ] && fzf="fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%}" || fzf="fzf"
|
||||||
|
|
||||||
|
if ! setopt | grep nonomatch > /dev/null; then
|
||||||
|
nnm=1
|
||||||
|
setopt nonomatch
|
||||||
|
fi
|
||||||
dir="$base"
|
dir="$base"
|
||||||
while [ 1 ]; do
|
while [ 1 ]; do
|
||||||
if [ -z "$dir" -o -d ${~dir} ]; then
|
if [ -z "$dir" -o -d ${~dir} ]; then
|
||||||
@ -35,11 +39,12 @@ _fzf_path_completion() {
|
|||||||
LBUFFER="$lbuf$matches$tail"
|
LBUFFER="$lbuf$matches$tail"
|
||||||
zle redisplay
|
zle redisplay
|
||||||
fi
|
fi
|
||||||
return
|
break
|
||||||
fi
|
fi
|
||||||
dir=$(dirname "$dir")
|
dir=$(dirname "$dir")
|
||||||
dir=${dir%/}/
|
dir=${dir%/}/
|
||||||
done
|
done
|
||||||
|
[ -n "$nnm" ] && unsetopt nonomatch
|
||||||
}
|
}
|
||||||
|
|
||||||
_fzf_all_completion() {
|
_fzf_all_completion() {
|
||||||
|
@ -574,7 +574,7 @@ end
|
|||||||
|
|
||||||
module CompletionTest
|
module CompletionTest
|
||||||
def test_file_completion
|
def test_file_completion
|
||||||
tmux.send_keys 'mkdir -p /tmp/fzf-test; touch /tmp/fzf-test/{1..100}; touch ~/fzf-home', :Enter
|
tmux.send_keys 'mkdir -p /tmp/fzf-test; touch /tmp/fzf-test/{1..100}; touch ~/fzf-home no~such~user', :Enter
|
||||||
tmux.prepare
|
tmux.prepare
|
||||||
tmux.send_keys 'cat /tmp/fzf-test/10**', :Tab, pane: 0
|
tmux.send_keys 'cat /tmp/fzf-test/10**', :Tab, pane: 0
|
||||||
tmux.until(1) { |lines| lines.item_count > 0 }
|
tmux.until(1) { |lines| lines.item_count > 0 }
|
||||||
@ -594,7 +594,17 @@ module CompletionTest
|
|||||||
tmux.send_keys :Enter
|
tmux.send_keys :Enter
|
||||||
tmux.until do |lines|
|
tmux.until do |lines|
|
||||||
tmux.send_keys 'C-L'
|
tmux.send_keys 'C-L'
|
||||||
lines[-1].include?('fzf-home')
|
lines[-1].end_with?('fzf-home')
|
||||||
|
end
|
||||||
|
|
||||||
|
# ~INVALID_USERNAME**<TAB>
|
||||||
|
tmux.send_keys 'C-u'
|
||||||
|
tmux.send_keys "cat ~such**", :Tab, pane: 0
|
||||||
|
tmux.until(1) { |lines| lines[-3].end_with? 'no~such~user' }
|
||||||
|
tmux.send_keys :Enter
|
||||||
|
tmux.until do |lines|
|
||||||
|
tmux.send_keys 'C-L'
|
||||||
|
lines[-1].end_with?('no~such~user')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user