zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: "Marc Cornellà" <marc.cornella@live.com>, zsh-workers@zsh.org
Subject: Re: [BUG] git checkout completion shows duplicated branch names
Date: Mon, 24 Sep 2018 18:00:00 +0000	[thread overview]
Message-ID: <20180924180000.m257nywzw3os6fwh@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <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

  reply	other threads:[~2018-09-24 18:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-24 14:51 Marc Cornellà
2018-09-24 16:04 ` Daniel Shahaf
2018-09-24 18:00   ` Daniel Shahaf [this message]
2018-09-25  0:24     ` Bart Schaefer
2018-09-25 16:50       ` Daniel Shahaf
2018-09-25  0:46     ` Oliver Kiddle
2018-09-25 16:43       ` Daniel Shahaf
2018-09-25 17:15         ` Bart Schaefer
2018-09-25 17:28           ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180924180000.m257nywzw3os6fwh@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=marc.cornella@live.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).