Package: zsh
Version: 5.9-1
Severity: normal
Tags: upstream fixed-upstream
Forwarded: https://www.zsh.org/mla/workers/2022/msg00652.html

Case-insensitive completion is buggy.

A first report: https://www.zsh.org/mla/workers/2022/msg00652.html

I've found the same bug (different testcase):

mkdir test-directory
cd test-directory
touch mpfr-impl.h mpfr-intmax.h
autoload -U compinit
compinit
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*'

Then type

  : m-i

and [Tab] to complete on "m-i". I get:

  : mpfr-iN.h

with the cursor over the period. The character "N" is incorrect.

I've attached Bart Schaefer's patch from

  https://www.zsh.org/mla/workers/2022/msg00652.html

(a.k.a. <https://zsh.org/workers/50325>).

-- Package-specific info:

Packages which provide vendor completions:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name             Version         Architecture Description
+++-================-===============-============-=======================================================================
ii  bubblewrap       0.6.2-1         amd64        utility for unprivileged 
chroot and namespace manipulation
ii  curl             7.83.1-2        amd64        command line tool for 
transferring data with URL syntax
ii  dpkg-dev         1.21.8          all          Debian package development 
tools
ii  git-extras       6.1.0-1         all          Extra commands for git
ii  mercurial-common 6.1.3-1         all          easy-to-use, scalable 
distributed version control system (common files)
ii  meson            0.62.2-1        all          high-productivity build system
ii  ninja-build      1.11.0-1        amd64        small build system closest in 
spirit to Make
ii  pass             1.7.4-5         all          lightweight directory-based 
password manager
ii  pulseaudio-utils 15.0+dfsg1-4+b1 amd64        Command line tools for the 
PulseAudio sound server
ii  qpdf             10.6.3-1        amd64        tools for transforming and 
inspecting PDF files
ii  systemd          251.2-5         amd64        system and service manager
ii  udev             251.2-5         amd64        /dev/ and hotplug management 
daemon
ii  vlc-bin          3.0.17.4-3      amd64        binaries from VLC
ii  youtube-dl       2021.12.17-1    all          downloader of videos from 
YouTube and other sites

The following files were modified:

/etc/systemd/journald.conf
/etc/systemd/logind.conf
/etc/systemd/system.conf

dpkg-query: no path found matching pattern /usr/share/zsh/vendor-functions/


-- System Information:
Debian Release: bookworm/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'stable-updates'), (500, 
'stable-security'), (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 5.18.0-2-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=POSIX, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages zsh depends on:
ii  libc6       2.33-7
ii  libcap2     1:2.44-1
ii  libtinfo6   6.3+20220423-2
ii  zsh-common  5.9-1

Versions of packages zsh recommends:
ii  libncursesw6  6.3+20220423-2
ii  libpcre3      2:8.39-14

Versions of packages zsh suggests:
ii  zsh-doc  5.9-1

-- no debconf information

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Description: Fix a case-insensitive completion bug (regression).
 https://zsh.org/workers/50325
Forwarded: https://www.zsh.org/mla/workers/2022/msg00652.html
Origin: commit 3e3cfabcc74dc79d4d8717c4e5859d8d01be6c54

diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index bb8359f1d..56e5509a4 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -1319,7 +1319,7 @@ pattern_match_equivalence(Cpattern lp, convchar_t wind, int wmtp,
     convchar_t lchr;
     int lmtp;
 
-    if (!PATMATCHINDEX(lp->u.str, wind, &lchr, &lmtp)) {
+    if (!PATMATCHINDEX(lp->u.str, wind-1, &lchr, &lmtp)) {
 	/*
 	 * No equivalent.  No possible match; give up.
 	 */
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 59abb4cc4..77ccdebf7 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -4383,7 +4383,7 @@ cfp_matcher_range(Cmatcher *ms, char *add)
 			 * word pattern.
 			 */
 			if ((ind = pattern_match_equivalence
-			     (m->word, ind, mt, addc)) != CHR_INVALID) {
+			     (m->word, ind+1, mt, addc)) != CHR_INVALID) {
 			    if (ret) {
 				if (imeta(ind)) {
 				    *p++ = Meta;

Reply via email to