From b60ef72c3d9f7585d30c141e54dd7e9665d302cd Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 11 May 2016 14:57:56 +0200 Subject: 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. --- share/completions/git.fish | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'share/completions') 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 -- cgit v1.2.3