From 7f1ea270081bb71eca42bafb781c29d45ae56741 Mon Sep 17 00:00:00 2001 From: EmilySeville7cfg Date: Thu, 25 Nov 2021 17:30:44 +1000 Subject: [PATCH] Windows options support in __fish_seen_argument --- share/functions/__fish_seen_argument.fish | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/share/functions/__fish_seen_argument.fish b/share/functions/__fish_seen_argument.fish index 170bd4fa1..6425faa5c 100644 --- a/share/functions/__fish_seen_argument.fish +++ b/share/functions/__fish_seen_argument.fish @@ -1,23 +1,30 @@ -function __fish_seen_argument --description 'Check whether argument used' - argparse 's/short=+' 'o/old=+' 'l/long=+' -- $argv +function __fish_seen_argument --description 'Check whether argument is used' + argparse 's/short=+' 'o/old=+' 'l/long=+' 'w/windows=+' -- $argv - set -l cmd (commandline -poc) - set -e cmd[1] - for t in $cmd + set --local tokens (commandline --current-process --tokenize --cut-at-cursor) + set --erase tokens[1] + + for t in $tokens for s in $_flag_s - if string match -qr "^-[A-z0-9]*"$s"[A-z0-9]*\$" -- $t + if string match --regex --quiet -- "^-[A-z0-9]*"$s"[A-z0-9]*\$" $t return 0 end end for o in $_flag_o - if string match -qr "^-$s\$" -- $t + if string match --quiet -- "-$s" $t return 0 end end for l in $_flag_l - if string match -q -- "--$l" $t + if string match --quiet -- "--$l" $t + return 0 + end + end + + for w in $_flag_w + if string match --quiet -- "/$w" $t return 0 end end