Skip to content

Incorrect handling of quoted & escaped parameters for Fish completions #2995

Closed

Description

@HansLehnert

Completions for parameters in quotes, partially quoted or with escaped characters (e.g. whitespace) don't work properly for Fish shell.

I believe the issue is that for fish completion, the incomplete paramater is passed through the COMP_CWORD environment variable and it's expected that it will be contained in COMP_WORDS as the last parameter. However, before doing this match COMP_WORDS is parsed, which quotes and unescapes the parameters, while COMP_CWORD is not causing the match to fail. See code here.

How to replicate

Consider the following command

@click.command()
@click.argument('bar', type=click.Choice(('hello world',)))
def main(bar: str):
    pass

Trying to complete foo hello in Fish will correctly return completion for foo hello\ world.

The following incomplete commands will not return any completions

  • foo hello\
  • foo "hello
  • foo "hello"

Environment:

  • Python version: 3.13.5
  • Click version: 8.2.1

Activity

  1. Rowlando13 commented on Jul 6, 2025

    @Rowlando13
    Member

    @HansLehnert I assume you meant Python 3.13.5?

  2. HansLehnert commented on Jul 6, 2025

    @HansLehnert
    ContributorAuthor

    @HansLehnert I assume you meant Python 3.13.5?

    yes, thanks

  3. added this to the milestone on Aug 12, 2025
  4. modified the milestones: , 8.3.0 on Aug 24, 2025
  5. locked as resolved and limited conversation to collaborators on Sep 8, 2025
  6. added
    shell completion
    on Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    shell completion

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions