From 7ad779ac00c975b3b6e00c1d1f7bc6f35d83d243 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sat, 26 Jan 2019 19:11:27 +0100 Subject: [PATCH] Remove __fish_can_complete_switches This was only used in __fish_should_complete_switches, and is a tiny helper function that is better integrated directly. Part of #5279. [ci skip] --- share/functions/__fish_can_complete_switches.fish | 14 -------------- .../functions/__fish_should_complete_switches.fish | 6 ++++-- 2 files changed, 4 insertions(+), 16 deletions(-) delete mode 100644 share/functions/__fish_can_complete_switches.fish diff --git a/share/functions/__fish_can_complete_switches.fish b/share/functions/__fish_can_complete_switches.fish deleted file mode 100644 index 9354f0892..000000000 --- a/share/functions/__fish_can_complete_switches.fish +++ /dev/null @@ -1,14 +0,0 @@ -# Returns whether it is at all possible (even if not recommended) -# to complete a -s or --long argument. -function __fish_can_complete_switches - # Search backwards - for arg in (commandline -ct)[-1..1] - if test "$arg" = "" - continue - else if not string match -qr -- "^-\S*\$" "$arg" - return 1 - end - end - - return 0 -end diff --git a/share/functions/__fish_should_complete_switches.fish b/share/functions/__fish_should_complete_switches.fish index 876a6a673..2563190fb 100644 --- a/share/functions/__fish_should_complete_switches.fish +++ b/share/functions/__fish_should_complete_switches.fish @@ -1,8 +1,10 @@ # Returns whether we *should* complete a -s or --long argument. # The preference is NOT to do so, i.e. prefer subcommands over switches. function __fish_should_complete_switches - if not __fish_can_complete_switches - return 1 + for arg in (commandline -ct)[-1..1] + if not string match -qr -- "^-\S*\$" "$arg" + return 1 + end end if string match -qr -- "^-" (commandline -ct)[-1] return 0