fix: use git-switch native completion for switch_branch

Use _git_switch/_git-switch instead of _git_checkout_branch/_git-branches
to stay closer to git's own completion suggestions.
This commit is contained in:
Wenxuan Zhang 2026-03-11 00:44:12 +08:00 committed by Wenxuan
parent 4c60265e4f
commit d62a34d0f7
2 changed files with 5 additions and 5 deletions

View file

@ -120,7 +120,7 @@ _git-forgit() {
stash_show) _git-stash-show ;;
stash_push) _git-add ;;
show) _git-show ;;
switch_branch) _git-branches ;;
switch_branch) _git-switch ;;
worktree) _git-worktree ;;
worktree_delete) _git-worktrees ;;
esac
@ -134,7 +134,7 @@ _git-forgit() {
compdef _git-add forgit::add
compdef _git-branches forgit::branch::delete
compdef _git-branches forgit::checkout::branch
compdef _git-branches forgit::switch::branch
compdef _git-switch forgit::switch::branch
compdef __git_recent_commits forgit::checkout::commit
compdef _git-checkout-file forgit::checkout::file
compdef __git_tags forgit::checkout::tag

View file

@ -125,7 +125,7 @@ _git_forgit()
squash) _git_log ;;
stash_show) _git_stash_show ;;
stash_push) _git_add ;;
switch_branch) _git_checkout_branch ;;
switch_branch) _git_switch ;;
worktree) _git_worktree ;;
worktree_delete) _git_worktrees ;;
esac
@ -148,7 +148,7 @@ then
__git_complete forgit::add _git_add
__git_complete forgit::branch::delete _git_branch_delete
__git_complete forgit::checkout::branch _git_checkout_branch
__git_complete forgit::switch::branch _git_checkout_branch
__git_complete forgit::switch::branch _git_switch
__git_complete forgit::checkout::commit _git_checkout
__git_complete forgit::checkout::file _git_checkout_file
__git_complete forgit::checkout::tag _git_checkout_tag
@ -175,7 +175,7 @@ then
__git_complete "${forgit_add}" _git_add
__git_complete "${forgit_branch_delete}" _git_branch_delete
__git_complete "${forgit_checkout_branch}" _git_checkout_branch
__git_complete "${forgit_switch_branch}" _git_checkout_branch
__git_complete "${forgit_switch_branch}" _git_switch
__git_complete "${forgit_checkout_commit}" _git_checkout
__git_complete "${forgit_checkout_file}" _git_checkout_file
__git_complete "${forgit_checkout_tag}" _git_checkout_tag