Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] compinit interactive mode overwrites command line



On Mon, May 12, 2025 at 10:58 PM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> There's a long thread about this starting at workers/50412.  It
> interacts with a thread from Marlon starting at workers/49242.

Ah, the archive didn't show me that connection, only the single mail
at w/49242, and I think it's still missing mails starting from the
other point too, I just see your patch saying you think it fixes the
issue, and then no further comments.

> On Mon, May 12, 2025 at 9:40 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> >
> > This change appears to fix it, but I just looked for MM_INTER in
> > complist.c and tried poking at it until something changed, so it's
> > very possible this breaks something else.
>
> All of my attempts focused on getting minfo.len / minfo.cur /
> minfo.insc to agree with the actual state of the command line before
> entering the code shared with do_single().
>
> >           * In interactive completion mode we don't insert
> >           * the completion onto the command line, instead
> >           * we show just what the user has typed and
> >           * the match so far underneath (stored in "status").
>
> I'm not sure this comment is definitive -- if you hit TAB and then
> continue interactive completion, the unambiguous prefix will have been
> inserted into the command line without the user typing.  Interactive
> mode only updates state on self-insert, which is how things get out of
> whack when you invoke completion another way.
>
> In short, I'll be very relieved if this patch actually fixes all the
> cases, and not just one special case.

I'm not sure what all the cases are, due to the above reason, but it
works in two cases I can come up with to test, and fails in a third.
starting point for all cases:
% ls --<tab> 12345678
1) start using down to cycle through the matches, nothing is overwritten
2) type a few characters, then press tab, then press down to cycle
through the matches, nothing is overwritten
3) type a few characters and directly press down to cycle without
pressing tab, in this case " 12" is overwritten. (seems to not matter
how many characters you typed).

The following fixes the third case but it would be an understatement
to say that this is a hack,
@@ -2637,6 +2631,10 @@ domenuselect(Hookdef dummy, Chdata dat)
        }
        do_last_key = 0;

+       if (mode == MM_INTER && cmd == Th(z_downlineorhistory) /* and
all other movement widgets here */) {
+           minfo.len -= 3;
+           mode = 0;
+       }
        if (!cmd || cmd == Th(z_sendbreak)) {
            zbeep();
             molbeg = -1;

I'm just posting it in case it sparks some inspiration (unlikely).

I haven't yet dared doing things like invoke
accept-and-infer-next-history to see what that does.

In any case, it's unlikely that my approach was the right one, it just
seemed at first like it worked, and I wasn't aware of the other
replies.

-- 
Mikael Magnusson




Messages sorted by: Reverse Date, Date, Thread, Author