Skip to content

Fix long option completion with equals#3486

Closed
sjh9714 wants to merge 1 commit into
pallets:mainfrom
sjh9714:fix-long-option-equals-completion
Closed

Fix long option completion with equals#3486
sjh9714 wants to merge 1 commit into
pallets:mainfrom
sjh9714:fix-long-option-equals-completion

Conversation

@sjh9714
Copy link
Copy Markdown

@sjh9714 sjh9714 commented May 20, 2026

Shell completion currently strips the long option assignment prefix when completing values typed as --option=value. That makes bash return no replacement for partial values and makes zsh replace the whole option with the bare completion value.

This keeps the parsed value incomplete for matching, but remembers the --option= prefix and applies it back to plain completion values. File and directory completion markers are left unchanged so shell-native path completion still receives the raw path fragment. Space-separated option values and short options keep their existing bare value completions.

fixes #2847

Tests

  • uv run pytest tests/test_shell_completion.py -k "long_option_equals" -q failed before the implementation with bare auto / always completions instead of --color=auto / --color=always.
  • uv run pytest tests/test_shell_completion.py -k "long_option_equals" -q
  • uv run pytest tests/test_shell_completion.py -q
  • uv run pytest tests -q
  • uv run ruff check src/click/shell_completion.py tests/test_shell_completion.py
  • git diff --check

Note: I used Codex to help inspect the shell completion path and draft the regression tests, but I reviewed the final diff and ran the listed verification commands locally.

@davidism davidism closed this May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long option completion with = broken

2 participants