From: m0viefreak <m0viefreak.cm@googlemail.com>
To: zsh-workers@zsh.org
Cc: m0viefreak <m0viefreak.cm@googlemail.com>
Subject: [PATCH] completion: matcher correspondence classes: fix offset
Date: Sun, 13 Mar 2016 23:36:14 +0100 [thread overview]
Message-ID: <1457908574-11020-1-git-send-email-m0viefreak.cm@googlemail.com> (raw)
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
next reply other threads:[~2016-03-13 22:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-13 22:36 m0viefreak [this message]
2021-12-23 20:24 ` Mikael Magnusson
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=1457908574-11020-1-git-send-email-m0viefreak.cm@googlemail.com \
--to=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).