fix: complete executables in fish for benchmark commands#896
Conversation
Add fish completion for positional benchmark commands using __fish_complete_command, and mark --reference with CommandString so its value completes executables as well. Fixes sharkdp#872 Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d9b8f46bee
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| fn patch_fish_completions(path: &Path) { | ||
| let mut content = fs::read_to_string(path).expect("read fish completions"); | ||
| if !content.contains("__fish_use_subcommand") { |
There was a problem hiding this comment.
Guard fish patch with a unique marker
The contains("__fish_use_subcommand") check prevents the patch from being applied in practice. build_command() defines no subcommands, and clap_complete’s fish generator already emits __fish_use_subcommand in generated completions for that case, so hyperfine.fish will already contain this token before patching. As a result, FISH_COMMAND_COMPLETION is never appended and the positional executable completion fix does not take effect. Check for a marker unique to the injected snippet (for example the comment line or the full complete -c hyperfine ... (__fish_complete_command) string) instead.
Useful? React with 👍 / 👎.
Summary
$PATHfor positional benchmark command arguments via__fish_use_subcommand+__fish_complete_command.ValueHint::CommandStringto--referenceso its value also completes executables in fish (matching--setup,--prepare, etc.).Fixes #872
Notes
Zsh already uses
_cmdstringfor benchmark commands. Fish lacked positional command completion becauseclap_completedoes not emit it forValueHint::CommandStringpositional args.Test plan
cargo fmtcargo testhyperfine.fishcontains__fish_use_subcommandcompletion and--referenceuses__fish_complete_commandMade with Cursor