From 57d7c46d228d725f47704c7a4c1c27fcbaaaba0d Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 7 Jan 2024 18:04:53 +0100 Subject: [PATCH] completions: fix some completions to not look at other commands on the command line --- share/completions/env.fish | 4 ++-- share/completions/ffmpeg.fish | 2 +- share/functions/__fish_complete_clang.fish | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/completions/env.fish b/share/completions/env.fish index 11ef71951..5648d1579 100644 --- a/share/completions/env.fish +++ b/share/completions/env.fish @@ -5,7 +5,7 @@ end # Returns 0 if we're after `env` and all previous tokens have an equal sign function __fish_env_defining_vars - not string match -ev -- = (commandline -o)[2..-2] | string match -rq . + not string match -ev -- = (commandline -op)[2..-2] | string match -rq . end # Returns 0 if we're after `env` and all previous tokens have not yet contained an equal sign @@ -17,7 +17,7 @@ end function __fish_env_redefine_vars set -l vars (set --names -x) - set cmdline "$(commandline -o)" + set cmdline "$(commandline -op)" for var in $vars if not string match -e -- $var= $cmdline echo $var= diff --git a/share/completions/ffmpeg.fish b/share/completions/ffmpeg.fish index 791195be8..8e3a0c9b6 100644 --- a/share/completions/ffmpeg.fish +++ b/share/completions/ffmpeg.fish @@ -290,7 +290,7 @@ function __fish_ffmpeg_complete_filter # echo -e "\n **** $filter_type **** \n" > /dev/tty - set -l filters_arg (commandline -o)[-1] + set -l filters_arg (commandline -op)[-1] if string match -rq -- '^-' $filters_arg # No filter name started __fish_ffmpeg_filters $filter_type diff --git a/share/functions/__fish_complete_clang.fish b/share/functions/__fish_complete_clang.fish index 1a493cd80..a845fbb8b 100644 --- a/share/functions/__fish_complete_clang.fish +++ b/share/functions/__fish_complete_clang.fish @@ -7,7 +7,7 @@ function __fish_complete_clang set -l prefix (commandline -ct | string replace -fr -- '^(.*=)[^=]*' '$1') # Don't hard-code the name of the clang binary - set -l clang (commandline -o)[1] + set -l clang (commandline -op)[1] # first get the completions from clang, with the prefix separated from the value by a comma $clang --autocomplete=(commandline -ct | string unescape | string replace -- "$prefix" "$prefix,") 2>/dev/null | # and put it in a format that fish understands