Compare commits

...

3 Commits

Author SHA1 Message Date
Junegunn Choi 767f1255ab
Make completion.bash load faster
* Reduce number of `__fzf_orig_completion < <(complete -p "$@" 2> /dev/null)`s
* Clean up options in fzf completion
* Remove telnet completion
4 weeks ago
Junegunn Choi fddbfe7b0e
Fix 'reload' not terminating closed standard input stream
Fix #3750
4 weeks ago
Junegunn Choi 4ab7fdc28e
Merge identical case clauses 4 weeks ago

@ -100,128 +100,77 @@ _fzf_opts_completion() {
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=" opts="
-h --help -h --help
-x --extended
-e --exact -e --exact
--extended-exact
+x --no-extended +x --no-extended
+e --no-exact
-q --query -q --query
-f --filter -f --filter
--literal --literal
--no-literal
--algo
--scheme --scheme
--expect --expect
--no-expect --disabled
--enabled --no-phony
--disabled --phony
--tiebreak --tiebreak
--bind --bind
--color --color
--toggle-sort
-d --delimiter -d --delimiter
-n --nth -n --nth
--with-nth --with-nth
-s --sort
+s --no-sort +s --no-sort
--track --track
--no-track
--tac --tac
--no-tac
-i -i
+i +i
-m --multi -m --multi
+m --no-multi
--ansi --ansi
--no-ansi
--no-mouse --no-mouse
+c --no-color +c --no-color
+2 --no-256
--black
--no-black
--bold
--no-bold --no-bold
--layout --layout
--reverse --reverse
--no-reverse
--cycle --cycle
--no-cycle
--keep-right --keep-right
--no-keep-right
--hscroll
--no-hscroll --no-hscroll
--hscroll-off --hscroll-off
--scroll-off --scroll-off
--filepath-word --filepath-word
--no-filepath-word
--info --info
--no-info
--inline-info
--no-inline-info
--separator --separator
--no-separator --no-separator
--scrollbar
--no-scrollbar --no-scrollbar
--jump-labels --jump-labels
-1 --select-1 -1 --select-1
+1 --no-select-1
-0 --exit-0 -0 --exit-0
+0 --no-exit-0
--read0 --read0
--no-read0
--print0 --print0
--no-print0
--print-query --print-query
--no-print-query
--prompt --prompt
--pointer --pointer
--marker --marker
--sync --sync
--no-sync
--async
--no-history
--history --history
--history-size --history-size
--no-header
--no-header-lines
--header --header
--header-lines --header-lines
--header-first --header-first
--no-header-first
--ellipsis --ellipsis
--preview --preview
--no-preview
--preview-window --preview-window
--height --height
--min-height --min-height
--no-height
--no-margin
--no-padding
--no-border
--border --border
--no-border-label
--border-label --border-label
--border-label-pos --border-label-pos
--no-preview-label
--preview-label --preview-label
--preview-label-pos --preview-label-pos
--no-unicode --no-unicode
--unicode
--margin --margin
--padding --padding
--tabstop --tabstop
--listen --listen
--no-listen
--clear
--no-clear --no-clear
--version --version
--" --"
case "${prev}" in case "${prev}" in
--algo)
COMPREPLY=( $(compgen -W "v1 v2" -- "$cur") )
return 0
;;
--scheme) --scheme)
COMPREPLY=( $(compgen -W "default path history" -- "$cur") ) COMPREPLY=( $(compgen -W "default path history" -- "$cur") )
return 0 return 0
@ -524,9 +473,10 @@ a_cmds="
find git grep gunzip gzip hg jar find git grep gunzip gzip hg jar
ln ls mv open rm rsync scp ln ls mv open rm rsync scp
svn tar unzip zip" svn tar unzip zip"
v_cmds="export unset printenv"
# Preserve existing completion # Preserve existing completion
__fzf_orig_completion < <(complete -p $d_cmds $a_cmds ssh 2> /dev/null) __fzf_orig_completion < <(complete -p $d_cmds $a_cmds $v_cmds unalias kill ssh 2> /dev/null)
if type _comp_load > /dev/null 2>&1; then if type _comp_load > /dev/null 2>&1; then
# _comp_load was added in bash-completion 2.12 to replace _completion_loader. # _comp_load was added in bash-completion 2.12 to replace _completion_loader.
@ -562,10 +512,21 @@ for cmd in $d_cmds; do
__fzf_defc "$cmd" _fzf_dir_completion "-o bashdefault -o nospace -o dirnames" __fzf_defc "$cmd" _fzf_dir_completion "-o bashdefault -o nospace -o dirnames"
done done
# Variables
for cmd in $v_cmds; do
__fzf_defc "$cmd" _fzf_var_completion "-o default -o nospace -v"
done
# Aliases
__fzf_defc unalias _fzf_alias_completion "-a"
# Processes
__fzf_defc kill _fzf_proc_completion "-o default -o bashdefault"
# ssh # ssh
__fzf_defc ssh _fzf_complete_ssh "-o default -o bashdefault" __fzf_defc ssh _fzf_complete_ssh "-o default -o bashdefault"
unset cmd d_cmds a_cmds unset cmd d_cmds a_cmds v_cmds
_fzf_setup_completion() { _fzf_setup_completion() {
local kind fn cmd local kind fn cmd
@ -587,10 +548,4 @@ _fzf_setup_completion() {
done done
} }
# Environment variables / Aliases / Hosts / Process
_fzf_setup_completion 'var' export unset printenv
_fzf_setup_completion 'alias' unalias
_fzf_setup_completion 'host' telnet
_fzf_setup_completion 'proc' kill
fi fi

@ -1876,9 +1876,7 @@ func parseOptions(opts *Options, allArgs []string) {
opts.Marker = firstLine(nextString(allArgs, &i, "selected sign string required")) opts.Marker = firstLine(nextString(allArgs, &i, "selected sign string required"))
case "--sync": case "--sync":
opts.Sync = true opts.Sync = true
case "--no-sync": case "--no-sync", "--async":
opts.Sync = false
case "--async":
opts.Sync = false opts.Sync = false
case "--no-history": case "--no-history":
opts.History = nil opts.History = nil

@ -147,7 +147,7 @@ func (r *Reader) feed(src io.Reader) {
} }
// We're not making any progress after 100 tries. Stop. // We're not making any progress after 100 tries. Stop.
if n == 0 && err == nil { if n == 0 {
break break
} }

@ -1955,6 +1955,11 @@ class TestGoFZF < TestBase
tmux.until { |lines| assert_equal 10, lines.item_count } tmux.until { |lines| assert_equal 10, lines.item_count }
end end
def test_reload_should_terminate_stadard_input_stream
tmux.send_keys %(ruby -e "STDOUT.sync = true; loop { puts 1; sleep 0.1 }" | fzf --bind 'start:reload(seq 100)'), :Enter
tmux.until { |lines| assert_equal 100, lines.item_count }
end
def test_clear_list_when_header_lines_changed_due_to_reload def test_clear_list_when_header_lines_changed_due_to_reload
tmux.send_keys %(seq 10 | #{FZF} --header 0 --header-lines 3 --bind 'space:reload(seq 1)'), :Enter tmux.send_keys %(seq 10 | #{FZF} --header 0 --header-lines 3 --bind 'space:reload(seq 1)'), :Enter
tmux.until { |lines| assert_includes lines, ' 9' } tmux.until { |lines| assert_includes lines, ' 9' }

Loading…
Cancel
Save