Repository navigation
Flag completion: keep the external completer's flags next to an argument completer, and drop carapace duplicates - #19554
Merged
Conversation
…ent completer, and drop carapace duplicates
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
Two problems with flag completion on externs that use
@complete external, such as the onesgenerate completionswrites.An argument completer hid the external completer's flags. Take an extern with
...args: external_arg@"nu-complete git remotes". Atgit 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-nfrom 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, sogit remote prune <Tab>still lists only remotes. When either completer is@interactive, the command-wide one runs only as the fallback. An@interactivecommand-wide completer isn't the site's first completer. An@interactiveargument 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
--limitwith a trailing space, so that a space follows the flag. The dedupe against declared flags compared values exactly, sojj log --li<Tab>offered both--limitand--limit. A trailing space no longer makes a value new.User-facing changes (Release notes)
@completeor 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.Additional notes