* [MINOR BUG] Duplicate results in tab-menu
@ 2022-06-23 9:54 Morten Nissov
2022-06-23 14:42 ` Duplicate results in _python - (Re: [MINOR BUG] Duplicate results in tab-menu) Eric Cook
0 siblings, 1 reply; 8+ messages in thread
From: Morten Nissov @ 2022-06-23 9:54 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1.1: Type: text/plain, Size: 421 bytes --]
Hi,
Others in the IRC hadn't experienced this bug so I'm asking here.
In some cases, when I tab to open the menu everything is duplicated, see
below for example
[image: image.png]
I've found this happens when my .zshrc contains
> zstyle ':completion:*:matches' group 'yes'
> zstyle ':completion:*' group-name ''
> zstyle ":completion:*" list-dirs-first true
> autoload -U compinit && compinit
>
>
Best regards,
Morten
[-- Attachment #1.2: Type: text/html, Size: 1145 bytes --]
[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 39189 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Duplicate results in _python - (Re: [MINOR BUG] Duplicate results in tab-menu)
2022-06-23 9:54 [MINOR BUG] Duplicate results in tab-menu Morten Nissov
@ 2022-06-23 14:42 ` Eric Cook
2022-06-24 5:41 ` Bart Schaefer
2022-06-24 14:40 ` Morten Nissov
0 siblings, 2 replies; 8+ messages in thread
From: Eric Cook @ 2022-06-23 14:42 UTC (permalink / raw)
To: zsh-users
On 6/23/22 05:54, Morten Nissov wrote:
> Hi,
>
> Others in the IRC hadn't experienced this bug so I'm asking here.
>
> In some cases, when I tab to open the menu everything is duplicated, see below for example
> image.png
> I've found this happens when my .zshrc contains
>
> |zstyle ':completion:*:matches' group 'yes' zstyle ':completion:*' group-name '' zstyle ":completion:*" list-dirs-first true autoload -U compinit && compinit
> |
>
>
> Best regards,
> Morten
Just the group-name and list-dirs-first styles being empty string and true are needed to cause the problem.
with ''python foo'' _python makes its way to _normal, returns (seemingly true) then compsys calls _default to
complete -default- for some reason that i am unsure of.
as a workaround disabling list-dirs-first for python would prevent the duplicates from happening:
zstyle ':completion::complete:python<->#(.<->)#::*' list-dirs-first false
but even with that, compsys seems to still tries to complete -default-.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Duplicate results in _python - (Re: [MINOR BUG] Duplicate results in tab-menu)
2022-06-23 14:42 ` Duplicate results in _python - (Re: [MINOR BUG] Duplicate results in tab-menu) Eric Cook
@ 2022-06-24 5:41 ` Bart Schaefer
2022-07-17 3:48 ` Bart Schaefer
2022-06-24 14:40 ` Morten Nissov
1 sibling, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2022-06-24 5:41 UTC (permalink / raw)
To: Eric Cook; +Cc: Zsh Users
On Thu, Jun 23, 2022 at 7:42 AM Eric Cook <llua@gmx.com> wrote:
>
> On 6/23/22 05:54, Morten Nissov wrote:
> > In some cases, when I tab to open the menu everything is duplicated, see below for example
>
> Just the group-name and list-dirs-first styles being empty string and true are needed to cause the problem.
There are some interacting things going on here.
First, _python uses
#compdef -P python[0-9.]#
This means to first try completions for commands matching the pattern,
and then try completions for any other context that matches, which in
this case happens to be -default-.
This is handled by _dispatch, which (after discovering that "python3"
matches the pattern), sets _compskip=default to indicate that it
should not try the -default- context after all, and then calls
_python.
Unfortunately _python calls _normal which sets _compskip='' again.
_normal is expecting _compskip to have come from _main_complete, but
instead it clobbers the local in _dispatch, so when control eventually
returns there, _dispatch goes ahead with completing for -default-.
This would be invisible except that list-dirs-first causes the results
of these two different contexts to be placed in separate completion
groups, and then group-name prevents them from being mutually
de-duplicated.
The trouble here is that the completion invoked by _dispatch is
explicitly allowed to change _compskip to control the behavior of
_dispatch. It just happens that any completion that relies on calling
_normal may do so incorrectly.
Now, as it happens there's an undocumented option of _normal to
prevent it from doing this, but using that option breaks the python3
completion because the -default- context is needed for the "script
argument". So the fix appears to be to make _compskip local to
_python, which seems a bit icky because it doesn't help with any other
completions that may have it wrong. Better suggestions?
diff --git a/Completion/Unix/Command/_python b/Completion/Unix/Command/_python
index e5bac18bb..2711b8fd3 100644
--- a/Completion/Unix/Command/_python
+++ b/Completion/Unix/Command/_python
@@ -3,7 +3,7 @@
# Python 2.7
# Python 3.9
-local curcontext="$curcontext" state state_descr line
+local curcontext="$curcontext" state state_descr line _compskip="$_compskip"
typeset -A opt_args
local -a args
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Duplicate results in _python - (Re: [MINOR BUG] Duplicate results in tab-menu)
2022-06-24 5:41 ` Bart Schaefer
@ 2022-07-17 3:48 ` Bart Schaefer
0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2022-07-17 3:48 UTC (permalink / raw)
To: Zsh Users; +Cc: Eric Cook, Dan Arad
On Thu, Jun 23, 2022 at 10:41 PM Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> The trouble here is that the completion invoked by _dispatch is
> explicitly allowed to change _compskip to control the behavior of
> _dispatch. It just happens that any completion that relies on calling
> _normal may do so incorrectly.
>
> [...] So the fix appears to be to make _compskip local to
> _python, which seems a bit icky because it doesn't help with any other
> completions that may have it wrong. Better suggestions?
As there's been no follow-up, and this also appears to address issues
raised in https://zsh.org/workers/45767, I'm going to go ahead and
commit the change to _python.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Duplicate results in _python - (Re: [MINOR BUG] Duplicate results in tab-menu)
2022-06-23 14:42 ` Duplicate results in _python - (Re: [MINOR BUG] Duplicate results in tab-menu) Eric Cook
2022-06-24 5:41 ` Bart Schaefer
@ 2022-06-24 14:40 ` Morten Nissov
2022-06-26 5:15 ` Bart Schaefer
1 sibling, 1 reply; 8+ messages in thread
From: Morten Nissov @ 2022-06-24 14:40 UTC (permalink / raw)
To: Eric Cook; +Cc: zsh-users
[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]
Regarding the workaround, as far as I can see `zstyle
':completion::complete:python<->#(.<->)#::*' list-dirs-first false` doesn't
actually fix the problem.
`zstyle ':completion::complete:python3::*' list-dirs-first false` does
however, though obviously only for python3.
Morten
On Thu, Jun 23, 2022 at 4:42 PM Eric Cook <llua@gmx.com> wrote:
> On 6/23/22 05:54, Morten Nissov wrote:
> > Hi,
> >
> > Others in the IRC hadn't experienced this bug so I'm asking here.
> >
> > In some cases, when I tab to open the menu everything is duplicated, see
> below for example
> > image.png
> > I've found this happens when my .zshrc contains
> >
> > |zstyle ':completion:*:matches' group 'yes' zstyle ':completion:*'
> group-name '' zstyle ":completion:*" list-dirs-first true autoload -U
> compinit && compinit
> > |
> >
> >
> > Best regards,
> > Morten
>
> Just the group-name and list-dirs-first styles being empty string and true
> are needed to cause the problem.
>
> with ''python foo'' _python makes its way to _normal, returns (seemingly
> true) then compsys calls _default to
> complete -default- for some reason that i am unsure of.
>
> as a workaround disabling list-dirs-first for python would prevent the
> duplicates from happening:
> zstyle ':completion::complete:python<->#(.<->)#::*' list-dirs-first false
>
> but even with that, compsys seems to still tries to complete -default-.
>
>
[-- Attachment #2: Type: text/html, Size: 1969 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Duplicate results in _python - (Re: [MINOR BUG] Duplicate results in tab-menu)
2022-06-24 14:40 ` Morten Nissov
@ 2022-06-26 5:15 ` Bart Schaefer
2022-06-26 5:18 ` Bart Schaefer
0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2022-06-26 5:15 UTC (permalink / raw)
To: Morten Nissov; +Cc: Eric Cook, Zsh Users
On Fri, Jun 24, 2022 at 7:40 AM Morten Nissov <morten.c.nissov@gmail.com> wrote:
>
> Regarding the workaround, as far as I can see `zstyle ':completion::complete:python<->#(.<->)#::*' list-dirs-first false` doesn't actually fix the problem.
That's because the context being tested is actually
:completion::complete:python3:: which considered "shorter than" the
pattern above, so the :completion:* zstyle is chosen instead. The
rules for deciding what's the "best match" for zstyle patterns are a
bit convoluted. Leave off the final * and you can leave the
number-match for python version.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Duplicate results in _python - (Re: [MINOR BUG] Duplicate results in tab-menu)
2022-06-26 5:15 ` Bart Schaefer
@ 2022-06-26 5:18 ` Bart Schaefer
2022-06-27 8:00 ` Morten Nissov
0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2022-06-26 5:18 UTC (permalink / raw)
To: Morten Nissov; +Cc: Eric Cook, Zsh Users
On Sat, Jun 25, 2022 at 10:15 PM Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> Leave off the final * and you can leave the
> number-match for python version.
Either of these also works:
# Leave out one colon
zstyle ':completion::complete:python<->#(.<->)#:*' list-dirs-first false
# Leave out the word "complete"
zstyle ':completion:*:python<->#(.<->)#::*' list-dirs-first false
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Duplicate results in _python - (Re: [MINOR BUG] Duplicate results in tab-menu)
2022-06-26 5:18 ` Bart Schaefer
@ 2022-06-27 8:00 ` Morten Nissov
0 siblings, 0 replies; 8+ messages in thread
From: Morten Nissov @ 2022-06-27 8:00 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Eric Cook, Zsh Users
[-- Attachment #1: Type: text/plain, Size: 836 bytes --]
Hopefully it's not something on my end, but it looks as though none of the
following works ether
- zstyle ':completion::complete:python<->#(.<->)#::' list-dirs-first
false
- zstyle ':completion::complete:python<->#(.<->)#:*' list-dirs-first
false
- zstyle ':completion:*:python<->#(.<->)#::*' list-dirs-first false
Morten
On Sun, Jun 26, 2022 at 7:18 AM Bart Schaefer <schaefer@brasslantern.com>
wrote:
> On Sat, Jun 25, 2022 at 10:15 PM Bart Schaefer
> <schaefer@brasslantern.com> wrote:
> >
> > Leave off the final * and you can leave the
> > number-match for python version.
>
> Either of these also works:
>
> # Leave out one colon
> zstyle ':completion::complete:python<->#(.<->)#:*' list-dirs-first false
>
> # Leave out the word "complete"
> zstyle ':completion:*:python<->#(.<->)#::*' list-dirs-first false
>
[-- Attachment #2: Type: text/html, Size: 1495 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-07-17 3:49 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-23 9:54 [MINOR BUG] Duplicate results in tab-menu Morten Nissov
2022-06-23 14:42 ` Duplicate results in _python - (Re: [MINOR BUG] Duplicate results in tab-menu) Eric Cook
2022-06-24 5:41 ` Bart Schaefer
2022-07-17 3:48 ` Bart Schaefer
2022-06-24 14:40 ` Morten Nissov
2022-06-26 5:15 ` Bart Schaefer
2022-06-26 5:18 ` Bart Schaefer
2022-06-27 8:00 ` Morten Nissov
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).