Skip to content
Myr

Add changelog entry, fix admonition and add test

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kevin Deldycke · committed by Kevin Deldycke · parent b7e5fd4 · Browse files · 3 files+17 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+17 added−3 removed

  • tests:+9 added−0 removed
  • other:+8 added−3 removed

3 files+17 added−3 removed

modified:src/click/shell_completion.py+3 added-3 removed
417 unmodified lines
418 return args, incomplete419420 def format_completion(self, item: CompletionItem) -> str:421 """422 .. versionchanged:: 8.4.0423 Escape newlines in value and help to fix completion errors with424 multi-line help strings.422 .. versionchanged:: 8.4.2423 Escape newlines and replace tabs with spaces in the help text to424 fix completion errors with multi-line help strings.425 """426 # According to https://fishshell.com/docs/current/cmds/complete.html427 # Command substitutions found in ARGUMENTS should return a newline-428 # separated list of arguments, and each argument may optionally have a tab
248 unmodified lines
modified:tests/test_shell_completion.py+9 added
10 unmodified lines
11from click.core import Group12from click.core import Option13from click.shell_completion import add_completion_class14from click.shell_completion import CompletionItem15from click.shell_completion import FishComplete16from click.shell_completion import shell_complete17from click.shell_completion import ShellComplete18from click.types import Choice19from click.types import File
556 unmodified lines
576 with warnings.catch_warnings(record=True) as current_warnings:577 assert not current_warnings, "There should be no warnings to start"578 _get_completions(cli, args=[], incomplete="")579 assert not current_warnings, "There should be no warnings after either"580581582def test_fish_format_completion_escapes_help():583 fc = FishComplete(Command("x"), {}, "x", "_X_COMPLETE")584 item = CompletionItem("--at", help="first\nsecond\tthird")585 # The newline is escaped to the literal characters backslash-n and the tab586 # becomes a space, so each completion stays on one line for fish.587 assert fc.format_completion(item) == "plain,--at\tfirst\\nsecond third"
modified:CHANGES.rst+5 added
3 unmodified lines
4-------------56Unreleased78- Fix Fish shell completion broken in ``8.4.0`` by :pr:`3126`. Newlines and9 tabs in option help text are now escaped, keeping the original completion10 format while still supporting multi-line help. :issue:`3502`11 :issue:`3043` :pr:`3504` :pr:`3508`121314Version 8.4.115-------------1617Released 2026-05-21
1474 unmodified lines