zsh-workers
 help / color / mirror / code / Atom feed
* Re: [BUG] complist interactive mode overwrites command line
       [not found] <8964126.CDJkKcVGEf.ref@phy-nordri>
@ 2022-07-15 13:39 ` Andrea Manenti
  2022-07-16 18:11   ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Andrea Manenti @ 2022-07-15 13:39 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 878 bytes --]

On Wed, 4 Aug 2021 19:30:10 +0300 Marlon Richert <marlon.richert@xxxxxxxxx> wrote:
> % zmodload zsh/complist
> % bindkey '^I' menu-select
> % MENUMODE=interactive
> % touch test{1,2}
> % : ; foobar
>     ^ 1. Type the above line in its entirety.
>       2. Place the cursor before the ;
>       3. Press Tab.
>       4. Press Enter.
> % : test1 bar
>     ^ Completion is written over existing buffer contents.

I am also experiencing this bug, I'm running zsh 5.9.

I hope that someone else is also interested in solving this because, unfortunately,
I lack the expertise to have a go at it.

If it can be helpful, this is my .zshrc configuration:

```
autoload -Uz compinit
compinit

setopt noautomenu
setopt globcomplete
bindkey '^i' complete-word
setopt nolisttypes

zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' menu yes select interactive
```

[-- Attachment #2: Type: text/html, Size: 3152 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] complist interactive mode overwrites command line
  2022-07-15 13:39 ` [BUG] complist interactive mode overwrites command line Andrea Manenti
@ 2022-07-16 18:11   ` Bart Schaefer
  2022-07-16 22:57     ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2022-07-16 18:11 UTC (permalink / raw)
  To: Andrea Manenti; +Cc: Zsh hackers list

On Fri, Jul 15, 2022 at 6:45 AM Andrea Manenti <andrea.manenti@yahoo.com> wrote:
>
> On Wed, 4 Aug 2021 19:30:10 +0300 Marlon Richert <marlon.richert@xxxxxxxxx> wrote:
> > % zmodload zsh/complist
> > % bindkey '^I' menu-select

I don't know if this is also a new thing, but menu-selection also
makes the display pretty confused when stepping through with the arrow
keys if some of the entries are longer than will fit on the command
line without wrapping at the right margin.  Try it in a directory with
a mix of very long and very short file names.

> > % MENUMODE=interactive
> > % touch test{1,2}
> > % : ; foobar
>
> >     ^ 1. Type the above line in its entirety.
> >       2. Place the cursor before the ;
> >       3. Press Tab.
> >       4. Press Enter.
> > % : test1 bar
> >     ^ Completion is written over existing buffer contents.

> I am also experiencing this bug, I'm running zsh 5.9.

The issue seems to be that interactive mode assumes you're going to
use it interactively -- as in, type a single character at a time until
you've reduced the set to only one match -- so it only adjusts the
buffer spacing on single keystrokes.  When you accept with TAB (or
ENTER) domenuselect() is relying on do_single() to fix everything up,
but the state required by do_single() is not fully populated.  I don't
know precisely what else is needed, though, and am out of time to
study it today.

> autoload -Uz compinit
> compinit
>
> setopt noautomenu
> setopt globcomplete
> bindkey '^i' complete-word
> setopt nolisttypes
>
> zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
> zstyle ':completion:*' menu yes select interactive

This configuration doesn't appear to matter to the underlying issue.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] complist interactive mode overwrites command line
  2022-07-16 18:11   ` Bart Schaefer
@ 2022-07-16 22:57     ` Bart Schaefer
       [not found]       ` <2844417.e9J7NaK4W3@phy-nordri>
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2022-07-16 22:57 UTC (permalink / raw)
  To: Andrea Manenti; +Cc: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

On Sat, Jul 16, 2022 at 11:11 AM Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> The issue seems to be that interactive mode assumes you're going to
> use it interactively -- as in, type a single character at a time until
> you've reduced the set to only one match -- so it only adjusts the
> buffer spacing on single keystrokes.  When you accept with TAB (or
> ENTER) domenuselect() is relying on do_single() to fix everything up,
> but the state required by do_single() is not fully populated.  I don't
> know precisely what else is needed, though, and am out of time to
> study it today.

Had to take a break from other stuff (weather too hot) so came back to
look at this.

I believe the following fixes it.  The example from Marlon's report
works, even after interactively typing the first few letters before
accepting.

[-- Attachment #2: complist.txt --]
[-- Type: text/plain, Size: 516 bytes --]

diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 0dc64db6a..f12c14e8e 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -2447,6 +2447,8 @@ domenuselect(Hookdef dummy, Chdata dat)
             strncpy(zlemetaline, origline, l);
             zlemetacs = origcs;
             setmstatus(status, NULL, 0 , 0, NULL, NULL, NULL);
+	    minfo.end -= minfo.len;
+	    minfo.len = 0;
         } else if (strpfx("search", s)) {
             mode = (strstr(s, "back") ? MM_BSEARCH : MM_FSEARCH);
         }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] complist interactive mode overwrites command line
       [not found]       ` <2844417.e9J7NaK4W3@phy-nordri>
@ 2022-07-22 16:32         ` Bart Schaefer
  2022-07-22 17:55           ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2022-07-22 16:32 UTC (permalink / raw)
  To: Andrea Manenti; +Cc: Zsh hackers list

On Mon, Jul 18, 2022 at 6:20 AM Andrea Manenti <andrea.manenti@yahoo.com> wrote:
>
> Great work, thanks! I patched it and it works, albeit with a little detail off:
>
> say I do ([] is the cursor)
>
> ```
> ls fo[] folder1
> <Tab>
> ls fo[] folder1
> folder2 folder3 ...
> <Tab>
> ls folder2/[] folder1
> (so far so good, but if <Tab> again)
> ls folder2/subfolder/[]older2/ folder1
> ```
>
> In other words, the thing that was just autocompleted ("older2/") gets repeated at the end.

I'm not able to reproduce the above with the minimal configuration
from your earlier email.  I do get a different odd behavior:

% ls fo[] folder1
% ls fo[] folder1
folder1 folder2 folder3

where "folder1" is selected and the "o" in "fo" at the prompt is
highlighted in boldface.  If accept one of the menu choices (e.g.,
press Enter):

% ls folder1/o[] folder1

I haven't figured out where the highlighting is coming from or why
that causes the insertion to occur one character to the left of the
cursor.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] complist interactive mode overwrites command line
  2022-07-22 16:32         ` Bart Schaefer
@ 2022-07-22 17:55           ` Bart Schaefer
  2022-07-22 18:23             ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2022-07-22 17:55 UTC (permalink / raw)
  To: Andrea Manenti; +Cc: Zsh hackers list

On Fri, Jul 22, 2022 at 9:32 AM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> % ls fo[] folder1
> folder1 folder2 folder3
>
> where "folder1" is selected and the "o" in "fo" at the prompt is
> highlighted in boldface.  If accept one of the menu choices (e.g.,
> press Enter):
>
> % ls folder1/o[] folder1

This seems to fix that, let's see if it handles your problem too.

diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 0dc64db6a..1b87103d7 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -2447,6 +2447,9 @@ domenuselect(Hookdef dummy, Chdata dat)
             strncpy(zlemetaline, origline, l);
             zlemetacs = origcs;
             setmstatus(status, NULL, 0 , 0, NULL, NULL, NULL);
+        minfo.insc = minfo.end;
+        minfo.end -= minfo.len;
+        minfo.len = 0;
         } else if (strpfx("search", s)) {
             mode = (strstr(s, "back") ? MM_BSEARCH : MM_FSEARCH);
         }


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] complist interactive mode overwrites command line
  2022-07-22 17:55           ` Bart Schaefer
@ 2022-07-22 18:23             ` Bart Schaefer
  2022-07-22 19:10               ` Andrea Manenti
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2022-07-22 18:23 UTC (permalink / raw)
  To: Andrea Manenti; +Cc: Zsh hackers list

On Fri, Jul 22, 2022 at 10:55 AM Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> This seems to fix that, let's see if it handles your problem too.

Ah, well, no, that just creates a different odd behavior.  Something
else still not right.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [BUG] complist interactive mode overwrites command line
  2022-07-22 18:23             ` Bart Schaefer
@ 2022-07-22 19:10               ` Andrea Manenti
  0 siblings, 0 replies; 8+ messages in thread
From: Andrea Manenti @ 2022-07-22 19:10 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh hackers list

>Subject: Re: [BUG] complist interactive mode overwrites command line
>Date: Friday, 22 July 2022, 20:23:46 CEST
>From: Bart Schaefer <schaefer@brasslantern.com>
>
> On Fri, Jul 22, 2022 at 10:55 AM Bart Schaefer
> <schaefer@brasslantern.com> wrote:
> >
> > This seems to fix that, let's see if it handles your problem too.
> 
> Ah, well, no, that just creates a different odd behavior.  Something
> else still not right.
>

This last patch does fix the weird behavior I pointed out previously but reintroduces the bug we started from the very beginning!

I wish I could be more helpful but I don't understand the code enough, I am always available for testing though. 




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [BUG] complist interactive mode overwrites command line
@ 2021-08-04 16:30 Marlon Richert
  0 siblings, 0 replies; 8+ messages in thread
From: Marlon Richert @ 2021-08-04 16:30 UTC (permalink / raw)
  To: Zsh hackers list

% zmodload zsh/complist
% bindkey '^I' menu-select
% MENUMODE=interactive
% touch test{1,2}
% : ; foobar
    ^ 1. Type the above line in its entirety.
      2. Place the cursor before the ;
      3. Press Tab.
      4. Press Enter.
% : test1 bar
    ^ Completion is written over existing buffer contents.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-07-22 19:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <8964126.CDJkKcVGEf.ref@phy-nordri>
2022-07-15 13:39 ` [BUG] complist interactive mode overwrites command line Andrea Manenti
2022-07-16 18:11   ` Bart Schaefer
2022-07-16 22:57     ` Bart Schaefer
     [not found]       ` <2844417.e9J7NaK4W3@phy-nordri>
2022-07-22 16:32         ` Bart Schaefer
2022-07-22 17:55           ` Bart Schaefer
2022-07-22 18:23             ` Bart Schaefer
2022-07-22 19:10               ` Andrea Manenti
2021-08-04 16:30 Marlon Richert

Code repositories for project(s) associated with this 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).