Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] git checkout completion shows duplicated branch names
- X-seq: zsh-workers 43531
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Marc Cornellà <marc.cornella@xxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: [BUG] git checkout completion shows duplicated branch names
- Date: Mon, 24 Sep 2018 18:00:00 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=h6eB/f VQHW9IZid2u8mD/agDFNj4akUDvoGWozuatxM=; b=Q8H/k4yKHFaaKkNbk1gUy3 8XYvMz5S1a8F6UjOcrvVRS73v8+XS/98IKyM0QdirvWmcrMhecN1nZn72wA6dCgR svd3V2qdGAcVE+GUCVmSdApxGQzKpLrwE50TGLP3n7UXAVRCM4zXmCNK9ce0CNOc 9T0NB2Gk1LtkxbOVI7468UmR2wJSbMG/urfi64nRlzZLni5A3sp2G+17dS9sBDzp j7NRHRAEaVTdQ7/MANsQ3mJztBMUvN3yrDhUTVg8XFncMqqv79PITWokutpQ4nLl UDRXO9AcLZ21jRWDSckVbefRP4eJgqlB8+eoQMpHrGs9YZK6qkuChDeQguWAP9qQ ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=h6eB/f VQHW9IZid2u8mD/agDFNj4akUDvoGWozuatxM=; b=Z1D+0vaUzZ6FL2cHOcnCVq pjJIOJ06RY4H/kVrR2wTytcbuiRrN3bM2YKbutDxqMpWImprieGKmSLfi+Tsbs83 Rm1Q6nRxU+8EnBcdSc8gsiFgpXGFKkz7blB2ZMClCmxXu3VrjtyOQrqa/Th6YH4Y QT5yjFTaggSv52NmQDgLB14M2hGUWZ9etT5AnY0IrNDyNY2Oo8OoqFuow392WP9L Wwhpr+h7D+FM/2hUM3Iz0cQylp06jlD19yu5yPYGaeSOfG8H4td08Uu1V2763fVS GLiDVXwUOMXMkWskvXVMiHW45fhpVGXk6civzwv3cmSE1VVkeuLmiFvYWUg7M3zw ==
- In-reply-to: <1537805063.1343776.1518857576.402E4300@webmail.messagingengine.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <AM0P195MB03370F6E436A8BA5D4ECE09D84170@AM0P195MB0337.EURP195.PROD.OUTLOOK.COM> <1537805063.1343776.1518857576.402E4300@webmail.messagingengine.com>
Daniel Shahaf wrote on Mon, Sep 24, 2018 at 16:04:23 +0000:
> Marc Cornellà wrote on Mon, 24 Sep 2018 14:51 +0000:
> > Furthermore, on versions prior to commit 4dddf3aa (< zsh-5.6), the
> > completion is even worse since a branch
> > is not fully completed even if there isn't any other branch with the
> > same prefix.
> >
> > So typing this:
> >
> > ~/repo% git checkout topic/<TAB>
> > topic/foo -- Initial commit
> > topic/foo
> >
> > gets completed to `git checkout topic` instead of the full branch name.
> >
>
> With 'zsh -f' + 'autoload compinit; compinit', «git checkout t<TAB>»
> gives me «git checkout topic/foo<CURSOR>» and a subsequent <TAB>
> displays possible completions. That is better than the behaviour you
> get, but I agree it shouldn't be treating this situation as an ambiguous
> completion. I don't know offhand where the relevant piece of code is,
> though. Probably in the internals of bin_compdescribe/bin_compadd?
>
> Here's a minimal example:
>
> _f() {
> local a=( foo:FOO bar:BAR ) expl
> _describe -t lorem "lorem" a
> _wanted ipsum expl 'ipsum' compadd foo bar
> }
> compdef _f f
> f f<TAB>
This seems to fix it:
[[[
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 8eca39447..6118c62c1 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -3160,9 +3160,7 @@ matcheq(Cmatch a, Cmatch b)
matchstreq(a->ppre, b->ppre) &&
matchstreq(a->psuf, b->psuf) &&
matchstreq(a->suf, b->suf) &&
- ((!a->disp && !b->disp && matchstreq(a->str, b->str)) ||
- (a->disp && b->disp && !strcmp(a->disp, b->disp) &&
- matchstreq(a->str, b->str)));
+ matchstreq(a->str, b->str);
}
/* Make an array from a linked list. The second argument says whether *
]]]
Can anyone think of a reason to consider matches different if their display
strings both exist, and differ; or if one of them has a display string and one
does not?
Marc, thanks for asking — this has been annoying me, too. ☺
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author