mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-25 23:21:15 -03:00
completions/cargo: remove xtask completions for now
We source "COMPLETE=fish cargo xtask" at completion load time. This means that completions will be missing if completions were requested before entering a fish-shell worktree. Also, as reported in [1], this will compile xtask even for non-fish projects, which is usually fast but not necessarily (it might download crates etc). As suggested in the initial revision of #12763, we could hardcode the output of $ COMPLETE=fish cargo xtask complete --keep-order --exclusive --command cargo --arguments \ "(COMPLETE=fish /home/johannes/git/fish-shell/target/debug/xtask -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))" but that might still be too intrusive because according to [2], calls to "cargo metadata" can be slow on big repos with hundreds of Cargo.toml files. [1]:959cbb4259 (r185615416)[2]:959cbb4259 (r185637424)FWIW, commit comments are also accessible via gh api -H "X-GitHub-Api-Version: 2026-03-10" \ /repos/fish-shell/fish-shell/commits/959cbb42597444577d26ed5ba6151ccb1d7f3600/comments
This commit is contained in:
@@ -851,17 +851,3 @@ if command -q cargo-asm
|
||||
complete -c cargo -n "__fish_seen_subcommand_from asm; and not __fish_is_switch" -xa "(__fish_cargo asm)"
|
||||
end
|
||||
end
|
||||
|
||||
# Determine whether the working directory is in a fish workspace.
|
||||
function __fish_cargo_is_in_fish_workspace
|
||||
command -v jq >/dev/null
|
||||
and __fish_cargo metadata --offline --no-deps --format-version=1 2>/dev/null |
|
||||
jq --exit-status -r '.packages | map(select(.name == "fish" and .homepage == "https://fishshell.com")) | any' >/dev/null
|
||||
end
|
||||
|
||||
# The sed command is a hack to only activate the conditions in fish workspaces.
|
||||
# Ideally, this would be handled by the completion generator,
|
||||
# but `clap_complete` does not have this capability.
|
||||
COMPLETE=fish __fish_cargo xtask 2>/dev/null |
|
||||
sed 's/^complete /complete --condition __fish_cargo_is_in_fish_workspace /' |
|
||||
source
|
||||
|
||||
Reference in New Issue
Block a user