From 684d360ece5e5e0367772795c05b5ec307ea893b Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 18 May 2026 06:59:04 +0800 Subject: [PATCH] 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]: https://github.com/fish-shell/fish-shell/commit/959cbb42597444577d26ed5ba6151ccb1d7f3600#r185615416 [2]: https://github.com/fish-shell/fish-shell/commit/959cbb42597444577d26ed5ba6151ccb1d7f3600#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 --- share/completions/cargo.fish | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/share/completions/cargo.fish b/share/completions/cargo.fish index 9923aa3c7..37871a252 100644 --- a/share/completions/cargo.fish +++ b/share/completions/cargo.fish @@ -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