Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Bug: git completion: __git_ignore_line ignores complete branch
- X-seq: zsh-workers 35969
- From: Daniel Hahler <genml+zsh-workers@xxxxxxxxxx>
- To: Zsh Hackers' List <zsh-workers@xxxxxxx>
- Subject: Bug: git completion: __git_ignore_line ignores complete branch
- Date: Sun, 02 Aug 2015 16:44:22 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= content-transfer-encoding:content-type:content-type:subject :subject:mime-version:user-agent:from:from:date:date:message-id :received:received; s=postfix2; t=1438526662; bh=JjPXAE20jU4A+nx 3ktC2BFmkhuqnC/x6IAOrk5RGPlI=; b=YISw2H57uA60AF6SNFdFxKtJbs2iVJV zE1mZHUPC6qtdK73PgT6znheJ+f6cZQ365JkvATD8kpw4DqKepLULlVfwtoNVCZN T+TSidH6kxLArKrzxYY8uxegI59UYqrvSmr2L3jTpBLnhnv4HTCN1jxPSdAT9WRJ ON2BSb5SmhmU=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
__git_ignore_line_inside_arguments seems to be responsible for an error when trying
to complete an already complete branch.
E.g. "git branch -D branch<tab>" results in:
-- no matches found: `branch-name' --
But "git branch -D branc<tab>" will complete "branch".
This is the function:
(( $+functions[__git_ignore_line] )) ||
__git_ignore_line () {
declare -a ignored
ignored=()
((CURRENT > 1)) &&
ignored+=(${line[1,CURRENT-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
((CURRENT < $#line)) &&
ignored+=(${line[CURRENT+1,-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
$* -F ignored
}
(( $+functions[__git_ignore_line_inside_arguments] )) ||
__git_ignore_line_inside_arguments () {
declare -a compadd_opts
zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F:
__git_ignore_line $* $compadd_opts
}
And it is used like this in _git-branch:
dependent_deletion_args+='*: :__git_ignore_line_inside_arguments __git_branch_names'
The problem is that it will ignore the current word, "branch", but should do so probably
only if it is not being completed currently, i.e. has a space at the end?!
It works when completing "branc", because then only "branc" will be ignored.
$line in the context of __git_ignore_line will be the part after "git branch -D", and $CURRENT will be 3. That seems to be off?!
For the case at hand, using ${line[1,CURRENT-3]//...} seems to fix it, but probably
an index matching the position in $line, and then -1 should be used?!
Regards,
Daniel.
-----BEGIN PGP SIGNATURE-----
iEYEARECAAYFAlW+LMYACgkQfAK/hT/mPgBbkQCgt4Y+fZ6zxT4Gn0IY8p4iLpcM
IaUAoOdcs+PuBtbLgRJukynIHCk2aw3l
=GQku
-----END PGP SIGNATURE-----
Messages sorted by:
Reverse Date,
Date,
Thread,
Author