From 8edc57ef40cd95d6215d00d54ad823ae67e87ee9 Mon Sep 17 00:00:00 2001 From: Tim Reddehase Date: Wed, 26 Sep 2018 09:42:30 +0200 Subject: [PATCH] allow subcommand_path to match even with flags With the old version flags between subcommands weren't allowed (as it was doing exact match). This solution is still not perfect (as it uses '.+') and could potentially swallow other subcommands. --- fish_completions.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fish_completions.go b/fish_completions.go index 65a8ef55..95f47b0b 100644 --- a/fish_completions.go +++ b/fish_completions.go @@ -35,9 +35,10 @@ function __fish_%s_no_subcommand --description 'Test if %s has yet to be given t return 0 end function __fish_%s_seen_subcommand_path --description 'Test whether the full path of subcommands is the current path' - set -l cmd (commandline -opc) - set -e cmd[1] - return (test (string trim -- "$argv") = (string trim -- "$cmd")) + set -l cmd (commandline -opc) + set -e cmd[1] + set -l pattern (string replace -a " " ".+" "$argv") + string match -r "$pattern" (string trim -- "$cmd") end # borrowed from current fish-shell master, since it is not in current 2.7.1 release function __fish_seen_argument