Fix auto-completion for ambiguous commands

fixes #7404