mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-10 07:16:23 -04:00
fix(fish): completions fail to load with fish >= 4.8.0
Fish started shipping git completions in the binary with 4.2.0 and deprecated the old completion files with 4.8.0. Update forgit’s fish completion loader to support both models: * prefer `status get-file completions/git.fish` (binary-embedded completions) * fall back to `$__fish_data_dir/completions/git.fish` (completion files) Also refactors loading into a helper function to allow early returns and reduce nesting.
This commit is contained in:
parent
d7d53288f9
commit
7070af0c01
|
|
@ -20,8 +20,29 @@ function __fish_forgit_worktrees
|
|||
git worktree list --porcelain 2>/dev/null | string match -r '^worktree .+' | string replace 'worktree ' ''
|
||||
end
|
||||
|
||||
# Load helper functions in git completion file
|
||||
not functions -q __fish_git && source $__fish_data_dir/completions/git.fish
|
||||
# Load git completion functions
|
||||
function __fish_forgit_load_git_completions
|
||||
if functions -q __fish_git
|
||||
return 0
|
||||
end
|
||||
|
||||
# Fish >= 4.2.0 ships git completions in its binary
|
||||
if set --local git_completions (status get-file completions/git.fish)
|
||||
printf '%s\n' $git_completions | source
|
||||
return 0
|
||||
end
|
||||
|
||||
# Older fish versions ship completions in a file
|
||||
set --local git_completions_file "$__fish_data_dir/completions/git.fish"
|
||||
if test -f "$git_completions_file"
|
||||
source "$git_completions_file"
|
||||
return 0
|
||||
end
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
__fish_forgit_load_git_completions || exit
|
||||
|
||||
# No file completion by default
|
||||
complete -c git-forgit -x
|
||||
|
|
|
|||
Loading…
Reference in a new issue