From: Mikael Magnusson <mikachu@gmail.com>
To: m0viefreak <m0viefreak.cm@googlemail.com>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH] completion: matcher correspondence classes: fix offset
Date: Thu, 23 Dec 2021 21:24:30 +0100 [thread overview]
Message-ID: <CAHYJk3RDwCZi1hfk0axb+0E5ySQ=brJYCW-CjFDMZhaaKDxniA@mail.gmail.com> (raw)
In-Reply-To: <1457908574-11020-1-git-send-email-m0viefreak.cm@googlemail.com>
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@googlemail.com> 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
next prev parent reply other threads:[~2021-12-23 20:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-13 22:36 m0viefreak
2021-12-23 20:24 ` Mikael Magnusson [this message]
2021-12-24 19:58 ` Bart Schaefer
2021-12-24 21:17 ` Bart Schaefer
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='CAHYJk3RDwCZi1hfk0axb+0E5ySQ=brJYCW-CjFDMZhaaKDxniA@mail.gmail.com' \
--to=mikachu@gmail.com \
--cc=m0viefreak.cm@googlemail.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).