Skip to content

Commit

Permalink
better
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickF1 committed Nov 5, 2023
1 parent 2255924 commit a81b9df
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions functions/_fzf_search_completions.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@
# (It thinks that it has to complete from / because `a_folder=/` looks like an argument to fish.
# - fish cannot give reliable context information on completions. Knowing whether a completion
# is a file or argument can only be determined via a heuristic.
function _fzf_search_completions --description "Shell completion using fzf"
set -f completions (complete --do-complete)

set -l fzf_output (
string join0 -- $completions \
| _fzf_wrapper \
function _fzf_search_completions --description "Search the completions for the current command line. Replace the current token with the selected completions."
set -l selected_completions (
complete --do-complete | string join0 |
_fzf_wrapper \
--read0 \
--print0 \
--ansi \
--multi \
--tiebreak=begin \
--query=$common_prefix \
--print-query \
$fzf_complete_description_opts \
$fzf_completions_opts \
| string split0
)
if test $status -eq 0
# Strip anything after last \t (the descriptions)
for i in (seq (count $results))
set results[$i] (string split --fields 1 --max 1 --right \t -- $results[$i])
# Strip away description
for completion in $selected_completions
set --append results (string split --fields 1 --max 1 --right \t -- $completion)
end
commandline --current-token --replace -- (string escape -- $results | string join ' ')
end
Expand Down

0 comments on commit a81b9df

Please sign in to comment.