Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] completion: matcher correspondence classes: fix offset
- X-seq: zsh-workers 38150
- From: m0viefreak <m0viefreak.cm@xxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] completion: matcher correspondence classes: fix offset
- Date: Sun, 13 Mar 2016 23:36:14 +0100
- Cc: m0viefreak <m0viefreak.cm@xxxxxxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=M+nAe8e+b5VGSx6wOJ403E84kb2b+3RVAqGYLo0CxjU=; b=OSLrXx4Wsk4hKkF5x4ENx2vyBQFon9nzjD8pPR0ePuq3VAnpUZvkhcJMD0+/dZGEco najNS0li9kYymrIOy1C7CF91CUz0XFvB0DY2ICQ12qP5+E6Jf1IIoeA1f3eIXY0OGDLP gTMr48IqDlPZDiydAGPv0yO/hb6RtB60kNDtr8aKbU3tc+ojATUqaK+1x7K+5W/DZG2S 4zgxY6RrsMskDdMPvEUHJI+pF/mkNwe73Akz/L4kx1Lv6rGpc9SLYheIHu9KZnpGKDoy 0aHhn0MJxW8ISHuACV1G5e9hXmWssj8MwFqWoPwuTaqFis04FLJdT8ZndwvqNT2DV4jr TGEA==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author