* Re: Autocomplete doesn't work correctly on certain folder names [not found] ` <CAN=4vMrYYYTpvWQgSa4ScQUNAC9_kHzDNFSy09fwBwD4w-37fQ@mail.gmail.com> @ 2023-04-21 3:35 ` Bart Schaefer 2023-04-21 19:59 ` Bart Schaefer 0 siblings, 1 reply; 4+ messages in thread From: Bart Schaefer @ 2023-04-21 3:35 UTC (permalink / raw) To: Zsh hackers list; +Cc: Ville Viitaharju [Moving to -workers] On Thu, Apr 20, 2023 at 6:05 AM Roman Perepelitsa <roman.perepelitsa@gmail.com> wrote: > > On Thu, Apr 20, 2023 at 2:56 PM Ville Viitaharju <racle@lonke.ro> wrote: > > > > zsh 5.9.0.1-dev (x86_64-pc-linux-gnu) > > > > Issue still exist when using cd long<tab><tab> > > I haven't tested it myself. My response was based on > https://zsh.org/workers/50875 but maybe I misunderstood it. workers/50325 fixed an off-by-one error in calling mb_patmatchindex(). It's possible there's a similar bug with related function mb_patmatchrange() or with the single-byte versions. If someone's willing to extract the matcher-list styles that oh-my-zsh is setting, it'd make this easier to check. Docker or not, I'm simply not going to wade through the rest of OMZ to investigate. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Autocomplete doesn't work correctly on certain folder names 2023-04-21 3:35 ` Autocomplete doesn't work correctly on certain folder names Bart Schaefer @ 2023-04-21 19:59 ` Bart Schaefer 2023-04-26 4:22 ` Jun T 0 siblings, 1 reply; 4+ messages in thread From: Bart Schaefer @ 2023-04-21 19:59 UTC (permalink / raw) To: Zsh hackers list; +Cc: Ville Viitaharju On Thu, Apr 20, 2023 at 8:35 PM Bart Schaefer <schaefer@brasslantern.com> wrote: > > If someone's willing to extract the matcher-list styles that oh-my-zsh > is setting, it'd make this easier to check. Docker or not, I'm simply > not going to wade through the rest of OMZ to investigate. On Fri, Apr 21, 2023 at 12:10 AM Carlo Sala <carlosalag@protonmail.com> wrote: > > Everything relevant in omz related to matcher-list styles is here. OK, thanks. The following matcher-list demonstrates the oddity: zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' OMZ actually uses [:lower:] and [:upper:] but I wanted to rule out that detail. No solution yet, but I believe this is a completely different bug. The one previously mentioned (workers/50325) was an off-by-one when selecting the character in the right-hand set of m:{a-zA-Z}={A-Za-z} to correspond to the character in the left-hand set. The bug reported by VIlle appears to be a problem with the input strings (that is, the file names). Given the provided example of my-longfoldername-firstname you-longfoldername-secondname I believe** the resulting partial completion should be y-longfoldername- but when the part before the first hyphen is longer in the second file name, the wrong character from the second name is chosen. I took a few stabs at different names and the ordering appears also to be important, e.g. if I try with jou-longfoldername-secondname mj-longfoldername-firstname I get the slightly different but less obviously wrong** answer -longfoldername- (that is, the "j" in common is not found at all). Other eyeballs on this would be appreciated. ** I may be incorrect about the expected answer, the juxtaposition of the prefix with the first hyphen also seems to matter. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Autocomplete doesn't work correctly on certain folder names 2023-04-21 19:59 ` Bart Schaefer @ 2023-04-26 4:22 ` Jun T 0 siblings, 0 replies; 4+ messages in thread From: Jun T @ 2023-04-26 4:22 UTC (permalink / raw) To: zsh-workers > 2023/04/22 4:59, Bart Schaefer <schaefer@brasslantern.com> wrote: > OK, thanks. The following matcher-list demonstrates the oddity: > > zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' (snip) > Given the provided example of > > my-longfoldername-firstname > you-longfoldername-secondname > > I believe** the resulting partial completion should be > > y-longfoldername- (snip) > ** I may be incorrect about the expected answer, the juxtaposition of > the prefix with the first hyphen also seems to matter. Please try putting a breakpoint at join_psfx(); this function is called with sfx=4 (i.e., true). When it is called for the first time, it does almost nothing, but at the second time, it calls sub_match() (compmatch.c:2493) } else if ((len = sub_match(&md, o->word, o->wlen, sfx)) != o->wlen) { Here, o->word="my-longfoldername-firstname", o->len=3, md.cl->word="you-longfoldername-secondname", md.cl->wlen=4. sub_match() returns 1 (= len), meaning that one character (the first '-' before the 'long') can be moved into the common prefix. Then, at line 2509: if ((joinl = join_sub(&md, *sstr + len, *slen - len, Here, *sstr="my-longfoldername-firstname", len=1, *slen=3 (*sstr+len = "y-longfoldername-firstname", *slen - len = 2). But md.str="-longfoldername-secondname", md.len=3. I first thought join_sub() should be called with the second argument "-longfoldername-firstname". This can be done by the patch below, and "apparently" it works: % cd long<TAB> gives % cd -long-foldername- and hitting more <TAB>s will work as expected. But if we look into join_sub(), lines 2221-2223, if (sfx) { ow += ol; nw += nl; } Before line 2222 (without the patch below) ow = str = "y-long...-firstname" and nw = "-long...-secondname". (with the patch ow = '-long...firstname"). Why these pointers need be advanced by ol=2 and nl=3? It looks as if join_sub() expects ow='my-long.." and nw="you-long.."?? I don't know what are the correct values for these pointers and lengths. I just hope my analysis will help someone to figure out the real fix. PS join_sub() tries all the matcher (including 'm:{a-zA-Z}={A-Za-z}'). Whether there is a '-' or not matters because '-' is not in the range '{a-zA-Z}'. diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c index ddcecd589..c9d4a3d24 100644 --- a/Src/Zle/compmatch.c +++ b/Src/Zle/compmatch.c @@ -2506,8 +2506,8 @@ join_psfx(Cline ot, Cline nt, Cline *orest, Cline *nrest, int sfx) Cline joinl; int jlen; - if ((joinl = join_sub(&md, *sstr + len, *slen - len, - &jlen, sfx, !(o->flags & CLF_JOIN)))) { + if ((joinl = join_sub(&md, *sstr + (sfx ? *slen - len : len), + *slen - len, &jlen, sfx, !(o->flags & CLF_JOIN)))) { /* We have one, insert it into the list. */ joinl->flags |= CLF_DIFF; if (len + jlen != *slen) { ^ permalink raw reply [flat|nested] 4+ messages in thread
* Autocomplete doesn't work correctly on certain folder names @ 2023-04-21 7:09 Carlo Sala 0 siblings, 0 replies; 4+ messages in thread From: Carlo Sala @ 2023-04-21 7:09 UTC (permalink / raw) To: zsh-workers [-- Attachment #1: Type: text/plain, Size: 273 bytes --] Sorry, I was not subscribed to this list and I cannot continue the thread. Everything relevant in omz related to matcher-list styles is [here](https://github.com/ohmyzsh/ohmyzsh/blob/07454029bd67239ce42aaa68b427fbbe8e428e7d/lib/completion.zsh#L16-L25). Thanks! Carlo Sala [-- Attachment #2: Type: text/html, Size: 890 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-26 4:23 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CAEQc7iXik1WSQYt3XzSkRugwo6HOLifX7rzTWbBXXoc4bFCsxQ@mail.gmail.com> [not found] ` <CAN=4vMoeZ3JFkfgmv7HgnNye68Ad0vZ1VJUjw28MwF9Gdh3h8g@mail.gmail.com> [not found] ` <CAEQc7iXVyTnEU+4aEOLX7ODivo1T1BOq+D=ynoSeuUc8VakujQ@mail.gmail.com> [not found] ` <CAN=4vMrYYYTpvWQgSa4ScQUNAC9_kHzDNFSy09fwBwD4w-37fQ@mail.gmail.com> 2023-04-21 3:35 ` Autocomplete doesn't work correctly on certain folder names Bart Schaefer 2023-04-21 19:59 ` Bart Schaefer 2023-04-26 4:22 ` Jun T 2023-04-21 7:09 Carlo Sala
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).