summaryrefslogtreecommitdiffstats
path: root/Completion
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2025-05-18 03:06:16 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2025-05-18 03:06:16 +0000
commit2ccf41e5772cbfb22802365a26872b796833a7c6 (patch)
tree255d536b7420a945a84de679bcc3ae8793447972 /Completion
parentunposted: Fix a ChangeLog typo reported offlist. (diff)
downloadzsh-2ccf41e5772cbfb22802365a26872b796833a7c6.tar
zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.tar.gz
zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.tar.bz2
zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.tar.lz
zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.tar.xz
zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.tar.zst
zsh-2ccf41e5772cbfb22802365a26872b796833a7c6.zip
github #134 (+ implement commit review suggestion): __git_worktrees: Use a library function
Using _describe makes the completions and descriptions line up in columns, and makes the function honour the list-separator style.
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_git6
1 files changed, 4 insertions, 2 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 702360ef3..95bd3096d 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -8514,6 +8514,7 @@ __git_worktrees () {
local -a records=( ${(ps.\n\n.)"$(_call_program directories git worktree list --porcelain)"} )
local -a directories descriptions
local i hash branch
+ local match mbegin mend
for i in $records; do
directories+=( ${${i%%$'\n'*}#worktree } )
hash=${${${"${(f)i}"[2]}#HEAD }[1,9]}
@@ -8527,9 +8528,10 @@ __git_worktrees () {
branch="[$branch]"
fi
- descriptions+=( "${directories[-1]}"$'\t'"$hash $branch" )
+ descriptions+=( "${directories[-1]//(#b)([\\:])/\\${match[1]}}":"$hash $branch" )
done
- _wanted directories expl 'working tree' compadd -ld descriptions -S ' ' -f -M 'r:|/=* r:|=*' -a directories
+
+ _describe -t directories 'working tree' descriptions -S ' ' -f -M 'r:|/=* r:|=*'
}
(( $+functions[__git_difftools] )) ||