diff options
author | Fabian Homborg <FHomborg@gmail.com> | 2016-05-11 14:57:56 +0200 |
---|---|---|
committer | Fabian Homborg <FHomborg@gmail.com> | 2016-05-11 15:03:05 +0200 |
commit | b60ef72c3d9f7585d30c141e54dd7e9665d302cd (patch) | |
tree | 70c10e11a2bf6c46beb5c25880bd5c51f19df278 /share/completions | |
parent | d2e79cf6f6589ae2cd8fb6ad1ac294f4486b0a2c (diff) |
git completion: Fix option-before-command for stash
Because it allows sub-subcommands, it has functions to determine which,
if any, is used. These were too simplistic.
Diffstat (limited to 'share/completions')
-rw-r--r-- | share/completions/git.fish | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/share/completions/git.fish b/share/completions/git.fish index ec604ed4..d23de7dd 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -115,21 +115,22 @@ function __fish_git_using_command end function __fish_git_stash_using_command - set cmd (commandline -opc) - if [ (count $cmd) -gt 2 ] - if [ $cmd[2] = 'stash' -a $argv[1] = $cmd[3] ] - return 0 - end - end - return 1 + set cmd (commandline -opc) + __fish_git_using_command stash; or return 2 + # The word after the stash command _must_ be the subcommand + set cmd $cmd[(contains -i -- "stash" $cmd)..-1] + set -e cmd[1] + set -q cmd[1]; or return 1 + contains -- $cmd[1] $argv; and return 0 + return 1 end function __fish_git_stash_not_using_subcommand - set cmd (commandline -opc) - if [ (count $cmd) -gt 2 -a $cmd[2] = 'stash' ] - return 1 - end - return 0 + set cmd (commandline -opc) + __fish_git_using_command stash; or return 2 + set cmd $cmd[(contains -i -- "stash" $cmd)..-1] + set -q cmd[2]; and return 1 + return 0 end function __fish_git_complete_stashes |