mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 08:56:43 +08:00
__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:
parent
563b4d2372
commit
c39780fefb
|
@ -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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#RUN: %fish %s
|
||||
#RUN: %fish --interactive %s
|
||||
# ^ interactive so we can do `complete`
|
||||
mkdir -p __fish_complete_directories/
|
||||
cd __fish_complete_directories
|
||||
mkdir -p test/buildroot
|
||||
|
@ -25,3 +26,7 @@ __fish_complete_directories test/data/
|
|||
__fish_complete_directories test/data/abc 'abc dirs'
|
||||
#CHECK: test/data/abc/ abc dirs
|
||||
#CHECK: test/data/abcd/ abc dirs
|
||||
|
||||
complete -c mydirs -l give-me-dir -a '(__fish_complete_directories)'
|
||||
complete -C'mydirs --give-me-dir='
|
||||
#CHECK: --give-me-dir=test/{{\t}}Directory
|
||||
|
|
Loading…
Reference in New Issue
Block a user