From 157737b787e2a72629f7d79deab83a99f09cf9c0 Mon Sep 17 00:00:00 2001
From: Tim Reddehase <tim.reddehase@xing.com>
Date: Tue, 25 Sep 2018 15:56:37 +0200
Subject: [PATCH] backport __fish_seen_argument.

---
 fish_completions.go      | 22 ++++++++++++++++++++++
 fish_completions_test.go |  1 +
 2 files changed, 23 insertions(+)

diff --git a/fish_completions.go b/fish_completions.go
index 19afae87..d1f0a6df 100644
--- a/fish_completions.go
+++ b/fish_completions.go
@@ -39,6 +39,28 @@ function __fish_%s_seen_subcommand_path --description 'Test whether the full pat
 	set -e cmd[1]
   return (test (string trim -- "$argv") = (string trim -- "$cmd"))
 end
+# borrowed from current fish-shell master, since it is not in current 2.7.1 release
+function __fish_seen_argument
+	argparse 's/short=+' 'l/long=+' -- $argv
+
+	set cmd (commandline -co)
+	set -e cmd[1]
+	for t in $cmd
+		for s in $_flag_s
+			if string match -qr "^-[A-z0-9]*"$s"[A-z0-9]*\$" -- $t
+				return 0
+			end
+		end
+
+		for l in $_flag_l
+			if string match -q -- "--$l" $t
+				return 0
+			end
+		end
+	end
+
+	return 1
+end
 `, cmd.Name(), cmd.Name(), strings.Join(subCommandNames, " "), cmd.Name()))
 }
 
diff --git a/fish_completions_test.go b/fish_completions_test.go
index 2cae7fc8..69eb9a94 100644
--- a/fish_completions_test.go
+++ b/fish_completions_test.go
@@ -88,6 +88,7 @@ func TestFishCompletions(t *testing.T) {
 	// check for preamble helper functions
 	check(t, output, "__fish_root_no_subcommand")
 	check(t, output, "__fish_root_seen_subcommand_path")
+	check(t, output, "__fish_seen_argument")
 
 	// check for subcommands
 	check(t, output, "-a echo")