Repository navigation
Conversation
2 tasks done
Contributor
|
Thanks for stepping in and putting this up |
fdncred
added a commit
that referenced
this pull request
Nov 16, 2026
…ent completer, and drop carapace duplicates (#19554) ## 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In a
def --wrappedcommand,what --<Tab>never called the completer on...args(#19097).Both
trailing_slotandresolve_argument_siteclassify any token starting with-asSiteKind::FlagName, which dispatches to flag-name completion only, even though a wrapped command binds an unknown--xto its rest parameter.This is a regression from #18761: before it, only a bare
-routed to flag completion, so--xon a wrapped command reached the rest completer, which took precedence over@completeas it does again now.SiteKind::FlagNamenow carries the positional the token would bind to.On a wrapped command whose positional declares a completer, the flag names are merged with that positional's completion, through the same
complete_argument_valuechain a plain positional takes.site_completerresolves the same completer, so an@interactiveone still runs inline.An undeclared rest parameter keeps flag-name completion only, since its shape fallback would list files for every
-typed.place.kindstaysflag-name.User-facing changes (Release notes)
Fixed a regression since 0.115 where custom completers on a
def --wrappedrest parameter were not called for arguments starting with-, sowhat --<Tab>only offered declared flags.Additional notes
fixes #19097