zsh-workers
 help / color / mirror / code / Atom feed
* _describe bug?
@ 2014-09-19 14:33 Vasiliy Ivanov
  2014-09-20  2:17 ` Bart Schaefer
  2014-09-20  2:38 ` Documentation (was Re: _describe bug?) Bart Schaefer
  0 siblings, 2 replies; 4+ messages in thread
From: Vasiliy Ivanov @ 2014-09-19 14:33 UTC (permalink / raw)
  To: zsh-workers

Hello,

Recently I noticed completion bug in _describe – if one provided name2 parameter (which made name2
array behave as completion list and name1 – as label:description list, according to zshcompsys),
then completion is offered only for (alphabetically?) first completion element:

#compdef testcmd
local -a lbl compl
lbl=(BBC BB BA AB AA)
compl=(bbc bb ba ab aa)
_describe 'whatever' lbl compl

$ testcmd <tab>
AA AB BA BB BBC

$ testcmd bb<tab>
BB BBC

$ testcmd b<tab>
BA BB BBC

$ testcmd a<tab>
<nothing>

I tried to dig from _describe module to the compadd but failed to debug this problem.

zsh 5.0.6

-- 
Regards,
  Vasiliy Ivanov <beelzebubbie.logs@gmail.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: _describe bug?
  2014-09-19 14:33 _describe bug? Vasiliy Ivanov
@ 2014-09-20  2:17 ` Bart Schaefer
  2014-09-20  9:21   ` Vasiliy Ivanov
  2014-09-20  2:38 ` Documentation (was Re: _describe bug?) Bart Schaefer
  1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2014-09-20  2:17 UTC (permalink / raw)
  To: zsh-workers

On Sep 19,  8:33pm, Vasiliy Ivanov wrote:
} 
} Recently I noticed completion bug in _describe - if one provided name2
} parameter (which made name2 array behave as completion list and name1
} - as label:description list, according to zshcompsys), then completion
} is offered only for (alphabetically?) first completion element:
} 
} #compdef testcmd
} local -a lbl compl
} lbl=(BBC BB BA AB AA)
} compl=(bbc bb ba ab aa)
} _describe 'whatever' lbl compl
} 
} $ testcmd a<tab>
} <nothing>

Puzzling how this one went unnoticed for so long.  The non-matching
descriptions were being discarded but the list of matching completions
was not being updated to correspond, so the arrays of descriptions and
completions were of different lengths and confusion resulted.


diff --git a/Completion/Base/Utility/_describe b/Completion/Base/Utility/_describe
index f899b0a..1a9f52f 100644
--- a/Completion/Base/Utility/_describe
+++ b/Completion/Base/Utility/_describe
@@ -96,7 +96,7 @@ while _tags; do
         fi
     
         if [[ -n $_mats ]]; then
-          compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_strs - \
+          compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_strs -O $_mats - \
                   "${(@)${(@M)${(@P)_mats}##([^:\\]|\\?)##}//\\(#b)(?)/$match[1]}"
         else
           compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_strs - \


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Documentation (was Re: _describe bug?)
  2014-09-19 14:33 _describe bug? Vasiliy Ivanov
  2014-09-20  2:17 ` Bart Schaefer
@ 2014-09-20  2:38 ` Bart Schaefer
  1 sibling, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2014-09-20  2:38 UTC (permalink / raw)
  To: zsh-workers

While we are on the subject, the documentation for compdescribe is wildly
inaccurate.

diff --git a/Doc/Zsh/mod_computil.yo b/Doc/Zsh/mod_computil.yo
index 593f85a..af537c9 100644
--- a/Doc/Zsh/mod_computil.yo
+++ b/Doc/Zsh/mod_computil.yo
@@ -33,12 +33,12 @@ arguments are like the definition arguments to tt(_describe) itself.
 
 Once tt(compdescribe) has been called with either the tt(-i) or the
 tt(-I) option, it can be repeatedly called with the tt(-g) option and
-the names of five arrays as its arguments.  This will step through the
-different sets of matches and store the options in the first array,
-the strings with descriptions in the second, the matches for these in
-the third, the strings without descriptions in the fourth, and the
-matches for them in the fifth array.  These are then directly given to
-tt(compadd) to register the matches with the completion code.
+the names of four parameters as its arguments.  This will step through
+the different sets of matches and store the value of tt(compstate[list])
+in the first scalar, the options for tt(compadd) in the second array,
+the matches in the third array, and the strings to be displayed in the
+completion listing in the fourth array.  The arrays may then be directly
+given to tt(compadd) to register the matches with the completion code.
 )
 findex(compfiles)
 item(tt(compfiles))(


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: _describe bug?
  2014-09-20  2:17 ` Bart Schaefer
@ 2014-09-20  9:21   ` Vasiliy Ivanov
  0 siblings, 0 replies; 4+ messages in thread
From: Vasiliy Ivanov @ 2014-09-20  9:21 UTC (permalink / raw)
  To: zsh-workers

Thanks, I had to work out this myself :)

On 09/20/14 08:17, Bart Schaefer wrote:
> On Sep 19,  8:33pm, Vasiliy Ivanov wrote:
> } 
> } Recently I noticed completion bug in _describe - if one provided name2
> } parameter (which made name2 array behave as completion list and name1
> } - as label:description list, according to zshcompsys), then completion
> } is offered only for (alphabetically?) first completion element:
> } 
> } #compdef testcmd
> } local -a lbl compl
> } lbl=(BBC BB BA AB AA)
> } compl=(bbc bb ba ab aa)
> } _describe 'whatever' lbl compl
> } 
> } $ testcmd a<tab>
> } <nothing>
> 
> Puzzling how this one went unnoticed for so long.  The non-matching
> descriptions were being discarded but the list of matching completions
> was not being updated to correspond, so the arrays of descriptions and
> completions were of different lengths and confusion resulted.
> 
> 
> diff --git a/Completion/Base/Utility/_describe b/Completion/Base/Utility/_describe
> index f899b0a..1a9f52f 100644
> --- a/Completion/Base/Utility/_describe
> +++ b/Completion/Base/Utility/_describe
> @@ -96,7 +96,7 @@ while _tags; do
>          fi
>      
>          if [[ -n $_mats ]]; then
> -          compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_strs - \
> +          compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_strs -O $_mats - \
>                    "${(@)${(@M)${(@P)_mats}##([^:\\]|\\?)##}//\\(#b)(?)/$match[1]}"
>          else
>            compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_strs - \
> 

-- 
Regards,
  Vasiliy Ivanov <beelzebubbie.logs@gmail.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-20  9:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-19 14:33 _describe bug? Vasiliy Ivanov
2014-09-20  2:17 ` Bart Schaefer
2014-09-20  9:21   ` Vasiliy Ivanov
2014-09-20  2:38 ` Documentation (was Re: _describe bug?) Bart Schaefer

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).