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 custom completion args for bash #320

Merged
merged 1 commit into from
Jun 4, 2021

Conversation

Frizlab
Copy link
Contributor

@Frizlab Frizlab commented Jun 1, 2021

I’ve noticed when using a custom completion in bash, the custom completion handler does not receive all the arguments as would be expected. This PR fixes that.

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

@kylemacomber
Copy link
Contributor

@swift-ci please test

@kylemacomber
Copy link
Contributor

@Frizlab could describe a simple concrete example where the current behavior returns the wrong result?

@Frizlab
Copy link
Contributor Author

Frizlab commented Jun 3, 2021

Here is an example! https://gitlab.com/frizlab-demo-projects/swift-argument-parser-example-for-pr-320

To see the bug, load the completion script in bash, and type ./.build/debug/example --option1 a (with a space after the a) and then trigger autocomplete. The file completion_debug.txt will be created, with one line per completion call, each line showing the content of the args array in the completion function.

You’ll see the args array only contain one entry, but it should be containing three.

With my fix, it does contain the three elements.

As a comparison one can try zsh completion, which does indeed show the three arguments as expected.

@natecook1000
Copy link
Member

Thanks for this fix, @Frizlab! 🎉

@natecook1000 natecook1000 merged commit e566395 into apple:main Jun 4, 2021
@Frizlab Frizlab deleted the fix_bash_custom_completion branch June 4, 2021 15:12
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

3 participants