Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Remove space added by completion
On 18.02.2014 17:54, Oliver Kiddle wrote:
> How about the following? This just uses zparseopts to get the suffixes
> and puts them in to each of the alternatives. The trickiest part is
> quoting. I've also added a compset -S call to handle an existing suffix.
>
> Oliver
>
> diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
> index a2cbf74..cfdbc4f 100644
> --- a/Completion/Unix/Command/_git
> +++ b/Completion/Unix/Command/_git
> @@ -5526,10 +5526,13 @@ __git_remote_branch_names_noprefix () {
> __git_commits () {
> # TODO: deal with things that __git_heads and __git_tags has in common (i.e.,
> # if both exists, they need to be completed to heads/x and tags/x.
> + local -a sopts ropt
> + zparseopts -E -a sopts S: r:=ropt R: q
> + sopts+=( $ropt:q )
> _alternative \
> - 'heads::__git_heads' \
> - 'commit-tags::__git_commit_tags' \
> - 'commit-objects::__git_commit_objects'
> + "heads::__git_heads $sopts" \
> + "commit-tags::__git_commit_tags $sopts" \
> + "commit-objects::__git_commit_objects"
> }
>
> (( $+functions[__git_heads] )) ||
> @@ -5595,10 +5598,12 @@ __git_commits2 () {
>
> (( $+functions[__git_commit_ranges] )) ||
> __git_commit_ranges () {
> + local -a suf
> if compset -P '*..(.|)'; then
> __git_commits $*
> else
> - __git_commits $* -qS ..
> + compset -S '..*' || suf=( -qS .. -r '.@~ ^:' )
> + __git_commits $* $suf
> fi
> }
>
>
While this works great when completing something *after* a branch name,
such as
$ git log foo<tab>bar<tab>
which then ends up in
$ git log foo-branch..bar-branch
this new suffix behavior is pretty bad in the following case:
$ git log ma<tab><return>
It ends up executing the following:
$ git log master..
The expected result (and behavior before this change) is:
$ git log master
which is something else entirely.
For some reason the auto-removable suffix does not get removed when
accept-line is called.
Is there a reason for this or a way to fix this?
Or a way to disable the newly introduced .. suffix entirely?
I'd rather hit backspace and add the dots myself when I actually want
them instead of having to remove them when they are inserted automatically.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author