Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] completion: matcher correspondence classes: fix offset



Were there ever any follwoups to this? I don't see any in the archive,
and the code still has the -1.

On 3/13/16, m0viefreak <m0viefreak.cm@xxxxxxxxxxxxxx> wrote:
> The "compfiles" function passes the matcher through the
> "cfp_matcher_range" function to turn a prefix into
> character classes. Example:
>
>   matcher: m:{a-z}={A-Z}
>   prefix: fo<tab>
>   file list: foo1.txt FOO2.txt
>
> the cfp_matcher_range function is supposed to turn the
> prefix into:
>
>   [fF][oO]
>
> However there is bug which causes the offset to shift
> by 1. Without this patch it returns:
>
>   [fE][oN]
>
> The bug was unnoticed before, because in the usual
> case -- that is when matcher-list is set -- _path_files
> calls compfiles -p ... "m:{a-z}={A-Z} m:{a-z}={A-Z}"
> with the matcher added twice. This causes
> "cfp_matcher_range" to do nothing at all, and instead
> the whole list of files in the directory is returned.
> Then it is filtered using compadd -D.
>
> A case where this bug surfaces is the following:
>
> Make sure no global matcher-list is set and set a single
> matcher instead:
>
>   zstyle -d ':completion:*' matcher-list
>   zstyle ':completion:*' matcher 'm:{a-z}={A-Z}'
>
> Now the completion
>
>   cat fo<tab>
>
> only offers "foo1.txt" but not "FOO2.txt".
>
> Questions I couldn't anwswer, yet:
> a) Why does "cfp_matcher_range" do nothing if more than
>    one matcher spec is given?
> b) Do we even need the "cfp_matcher_range" function
>    at all? Seems like the later compadd -D works just
>    fine and we could remove a whole bunch of unneeded
>    functions that are only called from cfp_matcher_range.
> c) Why does _path_files duplicate all matcher-list
>    entries when calling "compfiles -p"?
> ---
>  Src/Zle/compmatch.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
> index 0e41ac3..667d71d 100644
> --- a/Src/Zle/compmatch.c
> +++ b/Src/Zle/compmatch.c
> @@ -1218,7 +1218,7 @@ pattern_match_equivalence(Cpattern lp, convchar_t
> wind, int wmtp,
>      convchar_t lchr;
>      int lmtp;
>
> -    if (!PATMATCHINDEX(lp->u.str, wind-1, &lchr, &lmtp)) {
> +    if (!PATMATCHINDEX(lp->u.str, wind, &lchr, &lmtp)) {
>  	/*
>  	 * No equivalent.  No possible match; give up.
>  	 */
> --
> 2.5.0.234.gefc8a62
>
>


-- 
Mikael Magnusson




Messages sorted by: Reverse Date, Date, Thread, Author