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 (#556)
Some checks are pending
Some checks are pending
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
a3bfe847cf
commit
b2e5b46987
|
|
@ -20,8 +20,29 @@ function __fish_forgit_worktrees
|
||||||
git worktree list --porcelain 2>/dev/null | string match -r '^worktree .+' | string replace 'worktree ' ''
|
git worktree list --porcelain 2>/dev/null | string match -r '^worktree .+' | string replace 'worktree ' ''
|
||||||
end
|
end
|
||||||
|
|
||||||
# Load helper functions in git completion file
|
# Load git completion functions
|
||||||
not functions -q __fish_git && source $__fish_data_dir/completions/git.fish
|
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
|
# No file completion by default
|
||||||
complete -c git-forgit -x
|
complete -c git-forgit -x
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue