Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(completion): don't show positional args choices with option choices #2148

Merged
merged 2 commits into from Mar 23, 2022

Conversation

alan-agius4
Copy link
Contributor

@alan-agius4 alan-agius4 commented Mar 21, 2022

Previously, when both positional arguments and options has choices, during autocompletion we displayed both at the same time.

const positionalKeys =
this.yargs.getGroups()[this.usage.getPositionalGroupName()] || [];
const offset = Math.max(
this.indexAfterLastReset,
this.yargs.getInternalMethods().getContext().commands.length +
/* name of the script is first param */ 1
);
const positionalValues = argv._.slice(offset);
Copy link
Contributor Author

@alan-agius4 alan-agius4 Mar 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed since this is a redundant slice.

Previously, when both positional arguments and options has choices, during autocompletion we displayed both at the same time.
This is similar to the code in `completeOptionKey`
bcoe
bcoe approved these changes Mar 23, 2022
@bcoe bcoe merged commit b58b5bc into yargs:main Mar 23, 2022
7 checks passed
@bcoe
Copy link
Member

@bcoe bcoe commented Mar 23, 2022

@alan-agius4 thank you for the patch.

@alan-agius4 alan-agius4 deleted the positional-completions branch Mar 23, 2022
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.

None yet

2 participants