summaryrefslogtreecommitdiffstats
path: root/Completion/Base
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-11-19 10:19:07 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-11-19 10:19:07 +0000
commitb47a5f4f2b9a5f99d9bf95fc5e701ef6464f2c4d (patch)
treebf1207155681c4d9ff1867976992b35e48558818 /Completion/Base
parentzsh-workers/8678 (diff)
downloadzsh-b47a5f4f2b9a5f99d9bf95fc5e701ef6464f2c4d.tar
zsh-b47a5f4f2b9a5f99d9bf95fc5e701ef6464f2c4d.tar.gz
zsh-b47a5f4f2b9a5f99d9bf95fc5e701ef6464f2c4d.tar.bz2
zsh-b47a5f4f2b9a5f99d9bf95fc5e701ef6464f2c4d.tar.lz
zsh-b47a5f4f2b9a5f99d9bf95fc5e701ef6464f2c4d.tar.xz
zsh-b47a5f4f2b9a5f99d9bf95fc5e701ef6464f2c4d.tar.zst
zsh-b47a5f4f2b9a5f99d9bf95fc5e701ef6464f2c4d.zip
zsh-workers/8679
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/_jobs48
1 files changed, 41 insertions, 7 deletions
diff --git a/Completion/Base/_jobs b/Completion/Base/_jobs
index 40d6efc34..d9297086b 100644
--- a/Completion/Base/_jobs
+++ b/Completion/Base/_jobs
@@ -22,13 +22,47 @@ else
_description expl job
fi
-disp=()
-jobs=()
-for job in "$jids[@]"; do
- [[ -n "$desc" ]] &&
- disp=( "$disp[@]" "${pfx}${(r:2:: :)job} -- ${(r:COLUMNS-8:: :)jobtexts[$job]}" )
- jobs=( "$jobs[@]" "$job" )
-done
+if [[ -n "$desc" ]]; then
+ disp=()
+ for job in "$jids[@]"; do
+ [[ -n "$desc" ]] &&
+ disp=( "$disp[@]" "${pfx}${(r:2:: :)job} -- ${(r:COLUMNS-8:: :)jobtexts[$job]}" )
+ done
+fi
+
+if _style jobs strings; then
+ local texts i text str tmp
+
+ # Find shortest unambiguous strings.
+
+ texts=( "$jobtexts[@]" )
+ jobs=()
+ for i in "$jids[@]"; do
+ text="$jobtexts[$i]"
+ str="${text%% *}"
+ if [[ "$text" = *\ * ]]; then
+ text="${text#* }"
+ else
+ text=""
+ fi
+ tmp=( "${(@M)texts:#${str}*}" )
+ while [[ -n "$text" && $#tmp -ge 2 ]]; do
+ str="${str} ${text%% *}"
+ if [[ "$text" = *\ * ]]; then
+ text="${text#* }"
+ else
+ text=""
+ fi
+ tmp=( "${(@M)texts:#${str}*}" )
+ done
+
+ jobs=( "$jobs[@]" "$str" )
+ done
+
+ [[ -n "$pfx" && -n "$desc" ]] && disp=( "${(@)disp#%}" )
+else
+ jobs=( "$jids[@]" )
+fi
if [[ -n "$desc" ]]; then
compadd "$@" "$expl[@]" -ld disp - "%$^jobs[@]"