diff --git a/completion/available/bash-it.completion.bash b/completion/available/bash-it.completion.bash index dc007ec1..b61692f3 100644 --- a/completion/available/bash-it.completion.bash +++ b/completion/available/bash-it.completion.bash @@ -2,7 +2,7 @@ _bash-it-comp-enable-disable() { - local enable_disable_args="alias plugin completion" + local enable_disable_args="alias completion plugin" COMPREPLY=( $(compgen -W "${enable_disable_args}" -- ${cur}) ) } diff --git a/test/completion/bash-it.completion.bats b/test/completion/bash-it.completion.bats index 65984c2b..35d27312 100644 --- a/test/completion/bash-it.completion.bats +++ b/test/completion/bash-it.completion.bats @@ -43,16 +43,25 @@ function local_teardown { } function __check_completion () { + # Get the parameters as a single value + COMP_LINE=$* + # Get the parameters as an array eval set -- "$@" COMP_WORDS=("$@") - # Get the parameters as a single value - COMP_LINE=$* - # Index of the cursor in the line COMP_POINT=${#COMP_LINE} + # Get the last character of the line that was entered + COMP_LAST=$((${COMP_POINT} - 1)) + + # If the last character was a space... + if [[ ${COMP_LINE:$COMP_LAST} = ' ' ]]; then + # ...then add an empty array item + COMP_WORDS+=('') + fi + # Word index of the last word COMP_CWORD=$(( ${#COMP_WORDS[@]} - 1 )) @@ -68,6 +77,17 @@ function __check_completion () { assert_line "0" "vagrant vault vim" } +@test "completion bash-it: disable - show options" { + run __check_completion 'bash-it disable ' + assert_line "0" "alias completion plugin" +} + +@test "completion bash-it: disable - show options a" { + run __check_completion 'bash-it disable a' + + assert_line "0" "alias" +} + @test "completion bash-it: disable - provide nothing when atom is not enabled" { run __check_completion 'bash-it disable alias ato' assert_line "0" ""