Skip to content

fix: improve generated shell completions - #1331

Merged
dsherret merged 1 commit into
mainfrom
fix/shell-completions
Oct 10, 2026
Merged

dsherret merged 1 commit into
mainfrom
fix/shell-completions

Conversation

@dsherret

Copy link
Copy Markdown
Member

Improves the scripts generated by dprint completions <shell>.

Changes

  • Hidden items are no longer completed. editor-info, editor-service (and its --parent-pid) and --verbose were offered by every shell. They're now left out of the command that the completions are generated from.
  • --config-discovery completes its values (true, false, ignore-descendants, global). Previously bash offered file names and the other shells offered nothing. This only affects the completions; what the flag accepts when parsing is unchanged.
  • --lines no longer breaks the zsh spec. The colons in its value name ([file-path:]first:last[,first:last]...) weren't escaped, which ended the message early and turned the rest into a bogus completion action. They're now escaped in the completions and the flag completes file paths.
  • --excludes, --excludes-override and --includes-override complete file paths. zsh previously offered nothing for these.
  • --minimum-dependency-age no longer offers file names since it takes a duration or date.
  • Upgrades clap 4.5.4 → 4.6.7 and clap_complete 4.5.2 → 4.6.11, which improves the generators themselves:
    • zsh: --incremental= and --fail-fast= complete true/false (their optional value was previously dropped).
    • fish: nested subcommands such as dprint config add are tracked properly rather than picking up the completions of the top-level add.
    • bash: the current word is read more robustly and only the words before the cursor are used to determine the subcommand.

Tests

  • Asserts nothing hidden appears in the completions of any shell.
  • Asserts the zsh specs for --config-discovery, --incremental and --lines.
  • Asserts the global options stay last in every subcommand's help, since their position depends on how many subcommands are registered before them.

Help output and argument parsing are otherwise unchanged by the upgrade.

@dsherret
dsherret merged commit 98654bb into main Oct 10, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant