-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Bug Report
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
When using tab completions, wp-cli's behaviour is inconsistent with all other tab completions I've used, in the case where the word being completed is both an option itself and a prefix of another option. It does not seem to be specific to a shell but, rather, is caused by the potential options wp-cli returns from a given input. I've encountered this using the options beginning with --report or --regex when using wp search-replace but I imagine there are other cases.
Describe how other contributors can replicate this bug
E.g. type this then press Tab a couple of times:
$ wp search-replace --repActual behaviour "eats" the shorter option and completes the longer:
$ wp search-replace --report-changed-onlyDescribe what you expect as the correct outcome
The expected behaviour is to stop completing and display both options until the user disambiguates with Space, - or Enter:
$ wp search-replace --report
--report --report-changed-onlyTo get a like-for-like comparison:
- Run the following code in bash to set up a command named
wpxfor comparison (a safe no-op), and rudimentary completion for it:wpx () { : } _wpx () { if [ "$3" = "$1" ]; then COMPREPLY=( $( compgen -W search-replace -- "$2" ) ) else COMPREPLY=( $( compgen -W '--report --report-changed-only' -- "$2" ) ) fi } complete -F _wpx wpx
- Enter
wpxthen press Tab until the output does not change.
Let us know what environment you are running this on
I've experienced this in multiple environments in many versions of wp-cli, but all were on Linux.