mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-04 07:21:14 -03:00
Fix completions to cargo's --example option on macOS
The completions for the `--example` option are generated using `find`. The `find` utility on macOS will produce the following output when the path argument has a trailing slash: ``` ~/bat $ find ./examples/ ./examples/ ./examples//cat.rs ./examples//advanced.rs ./examples//simple.rs ./examples//list_syntaxes_and_themes.rs ./examples//yaml.rs ``` And will produce this output if the path does NOT have a trailing slash: ``` ~/bat $ find ./examples ./examples ./examples/cat.rs ./examples/advanced.rs ./examples/simple.rs ./examples/list_syntaxes_and_themes.rs ./examples/yaml.rs ``` The extra slash after `examples` ends up in the completion suggestions which is incorrect: ``` ~/bat $ cargo run --example <TAB> /advanced /cat /list_syntaxes_and_themes /simple /yaml ``` Unlike on my Linux box where `find` doesn't output the trailing slash: ``` ~/bat $ cargo run --example <TAB> advanced cat inputs list_syntaxes_and_themes simple yaml ``` Importantly, I get the same (correct) output on Linux even without the trailing slash in the path argument to `find`.
This commit is contained in:
committed by
David Adam
parent
701b7450df
commit
7d5c64a731
@@ -17,7 +17,7 @@ function __list_cargo_examples
|
||||
return
|
||||
end
|
||||
|
||||
find ./examples/ -mindepth 1 -maxdepth 1 -type f -name "*.rs" -or -type d \
|
||||
find ./examples -mindepth 1 -maxdepth 1 -type f -name "*.rs" -or -type d \
|
||||
| string replace -r './examples/(.*?)(?:.rs)?$' '$1'
|
||||
end
|
||||
for x in bench b build r run rustc t test
|
||||
|
||||
Reference in New Issue
Block a user