Skip to content

No completion for choices with whitespace. #32

@mhils

Description

@mhils

Hi there,

Thanks for the fantastic library! 😃 Small bug report: I am encountering some issues with completing arguments that contain whitespace:

@click.command()
@click.option("--foo", type=click.Choice(["Foo Bar", "Foo Qux"]))
def cli(foo):
    print(foo)
λ cli --foo
<TAB>
λ cli --foo Foo\ 
<TAB>
(nothing changes and no options are displayed)

click-completion: 0.5.2
shell: fish

My suspicion was that the .endswith check here could be culprit:

args = split_args(commandline)[1:]
if args and not commandline.endswith(' '):
incomplete = args[-1]
args = args[:-1]
else:
incomplete = ''
I patched split_args to return an (args, incomplete) tuple, but that did not cut it (edit: see below). Given that the changes got rather messy at this point, I stopped here hoping there might be an easier fix. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions