zsh-workers
 help / color / mirror / code / Atom feed
From: Marlon Richert <marlon.richert@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] Improve extra-verbose completion of array params
Date: Tue, 27 Apr 2021 13:28:36 +0300	[thread overview]
Message-ID: <CAHLkEDsLhV6ZWoo3G-ULG0o6TvBtnE8n7c+sjeYuNz3yZ7bRoQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 100 bytes --]

This patch improves the extra-verbose completion display strings for
arrays and associative arrays.

[-- Attachment #2: 0001-Improve-extra-verbose-completion-of-array-params.txt --]
[-- Type: text/plain, Size: 3116 bytes --]

From b2bde2a745693d45036733e8c0169f1c0343200b Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlon.richert@gmail.com>
Date: Tue, 27 Apr 2021 13:24:25 +0300
Subject: [PATCH] Improve extra-verbose completion of array params

---
 Completion/Zsh/Type/_parameters |  8 +++-----
 Test/Y01completion.ztst         | 14 +++++++++-----
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/Completion/Zsh/Type/_parameters b/Completion/Zsh/Type/_parameters
index 00c181e11..2cf8c229a 100644
--- a/Completion/Zsh/Type/_parameters
+++ b/Completion/Zsh/Type/_parameters
@@ -11,8 +11,8 @@ if compset -P '*:'; then
   return
 fi
 
-local MATCH i pfilt
-local -i MBEGIN MEND nm=$compstate[nmatches]
+local i pfilt 
+local -i nm=$compstate[nmatches]
 local -a expl pattern=(-g \*) normal described verbose faked fakes tmp
 
 zstyle -t ":completion:${curcontext}:parameters" prefix-needed &&
@@ -27,8 +27,7 @@ if zstyle -t ":completion:${curcontext}:parameters" extra-verbose; then
   )
   compadd "$@" "$expl[@]" -D described -a - described
   if (( $#described )); then
-    verbose=(
-        ${described[@]:/(#m)*/"${MATCH}:${(@q+)${(Pkv@q+)MATCH}//\\/\\\\}"} )
+    verbose=( ${${${(f@)"$( typeset -m $described )"}/=/:}[@]//'\'/'\\'} )
     _describe -t parameters parameter verbose "$@" "$expl[@]"
   fi
 
@@ -52,4 +51,3 @@ compadd "$@" "$expl[@]" - "$normal[@]" "${(@)fakes:|described}" \
     "${(@)${(@)${(@M)faked:#${~pattern[2]}}%%:*}:|described}"
 
 (( compstate[nmatches] > nm ))
-return 0
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index 2c6d25d9a..882a0adc4 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -255,15 +255,18 @@ F:regression test workers/31611
 >FI:{file1}
 >FI:{file2}
 
-  comptesteval "bar=({$'\\0'..$'\\C-?'}); baz=\$bar"
+  comptesteval "typeset -a bar=({$'\\0'..$'\\C-?'})"
+  comptesteval 'typeset -A bat=( "$bar[@]" )'
+  comptesteval 'typeset bay="$bar"'
   comptesteval 'zstyle ":completion:*:parameters" extra-verbose yes'
-  comptesteval 'zstyle ":completion:*" fake-parameters bar baz:array'
+  comptesteval 'zstyle ":completion:*" fake-parameters bar bat bay'
   comptest $': $ba\t'
 0:extra-verbose shows parameter values
 >line: {: $ba}{}
 >DESCRIPTION:{parameter}
->NO:{bar  -- '^@' '^A' '^B' '^C' '^D' '^E' '^F' '^G' '^H' '\t' '\n' '^K' '^L' '^M}
->NO:{baz  -- '^@ ^A ^B ^C ^D ^E ^F ^G ^H \t \n ^K ^L ^M ^N ^O ^P ^Q ^R ^S ^T ^U ^}
+>NO:{bar  -- ( '^@' '^A' '^B' '^C' '^D' '^E' '^F' '^G' '^H' '\t' '\n' '^K' '^L' '}
+>NO:{bat  -- ( [' ']='!' ['"']='#' ['$']=% ['&']=\' ['(']=')' ['*']=+ [,]=- [.]=/}
+>NO:{bay  -- '^@ ^A ^B ^C ^D ^E ^F ^G ^H \t \n ^K ^L ^M ^N ^O ^P ^Q ^R ^S ^T ^U ^}
 
   comptesteval "path=( $ZTST_srcdir:A )"
   comptesteval 'typeset -H paths=HIDDEN'
@@ -280,7 +283,8 @@ F:regression test workers/31611
 >line: {: $ba}{}
 >DESCRIPTION:{parameter}
 >NO:{bar}
->NO:{baz}
+>NO:{bat}
+>NO:{bay}
 
   comptesteval '_tst() { local disp=( {a..z} ); compadd -ld disp $disp[@]; comppostfuncs=( _pst ) }'
   comptesteval '_pst() { local disp=( "<INSERT>$compstate[insert]</INSERT>" ); compadd -Qld disp $disp }'
-- 
2.31.1


             reply	other threads:[~2021-04-27 10:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 10:28 Marlon Richert [this message]
2021-05-09 17:47 ` Lawrence Velázquez
2021-05-16 16:12   ` Lawrence Velázquez
2021-05-16 16:18     ` Mikael Magnusson
2021-05-16 19:40       ` Marlon Richert
2021-05-16 22:09 ` Oliver Kiddle
2021-05-17 11:58   ` Marlon Richert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHLkEDsLhV6ZWoo3G-ULG0o6TvBtnE8n7c+sjeYuNz3yZ7bRoQ@mail.gmail.com \
    --to=marlon.richert@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).