Skip to content

Flag completion: keep the external completer's flags next to an argument completer, and drop carapace duplicates - #19554

Merged
fdncred merged 1 commit into
nushell:mainfrom
fdncred:flag_completion_merge
Nov 16, 2026
Merged

fdncred merged 1 commit into
nushell:mainfrom
fdncred:flag_completion_merge

Conversation

@fdncred

@fdncred fdncred commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Description

Two problems with flag completion on externs that use @complete external, such as the ones generate completions writes.

An argument completer hid the external completer's flags. Take an extern with ...args: external_arg@"nu-complete git remotes". At git remote prune -<Tab>, the argument completer answered (with remote names), and since #19130 an answering argument completer overrides the command-wide one. So flags that only the external completer knows, such as -n from carapace, never showed up. Now, at a flag token, the command-wide completer's flags are added to whatever the argument completer answers. The command-wide completer still runs only once per Tab, because the same result is also the argument completer's fallback. Argument positions keep the existing contract, so git remote prune <Tab> still lists only remotes. When either completer is @interactive, the command-wide one runs only as the fallback. An @interactive command-wide completer isn't the site's first completer. An @interactive argument completer (a picker) runs without it, so neither a pick nor a cancel gets the command-wide completer's flags mixed in.

carapace duplicated every declared flag. carapace returns values like --limit with a trailing space, so that a space follows the flag. The dedupe against declared flags compared values exactly, so jj log --li<Tab> offered both --limit and --limit . A trailing space no longer makes a value new.

User-facing changes (Release notes)

  • At a flag token, the flags that @complete or the external completer lists now show up even when the argument's own completer answers. Argument values still come from the argument's completer alone.
  • Flags that carapace returns with a trailing space are no longer listed a second time next to the declared flag.

Additional notes

@fdncred fdncred added notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Nov 16, 2026
@fdncred
fdncred merged commit 9736153 into nushell:main Nov 16, 2026
15 checks passed
@fdncred
fdncred deleted the flag_completion_merge branch November 16, 2026 21:29
@github-actions github-actions Bot added this to the v0.118.0 milestone Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant