__fish_complete_directories: Remove --foo= from token

Otherwise this would complete

`git --exec-path=foo`, by running `complete -C"'' --exec-path=foo"`,

which would print "--exec-path=foo", and so it would end as

`git --exec-path=--exec-path=foo` because the "replaces token" bit was
lost.

I'm not sure how to solve it cleanly - maybe an additional option to
`complete`?

Anyway, for now this
Fixes #9538.
This commit is contained in:
Fabian Boehm
2023-03-27 22:55:45 +02:00
parent 563b4d2372
commit c39780fefb
2 changed files with 11 additions and 2 deletions

View File

@@ -9,7 +9,11 @@ function __fish_complete_directories -d "Complete directory prefixes" --argument
end
if not set -q comp[1]
set comp (commandline -ct)
# No token given, so we use the current commandline token.
# If we have a --name=val option, we need to remove it,
# or the complete -C below would keep it, and then whatever complete
# called us would add it again (assuming it's in the current token)
set comp (commandline -ct | string replace -r -- '^-[^=]*=' '' $comp)
end
# HACK: We call into the file completions by using an empty command