Skip to content

Commit 15b34e8

Browse files
committed
Cleanup #3126
Link to PR in changelog, move implementation details to Python code, fix changed version and align `.gitignore` syntax
1 parent 9ad2e32 commit 15b34e8

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ dist/
66
htmlcov/
77
.tox/
88
docs/_build/
9-
.venv
9+
.venv/

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Unreleased
4949
replacing the ``start`` built-in which cannot be invoked without
5050
``shell=True``. :issue:`3164` :pr:`3186`
5151
- Fix Fish shell completion errors when option help text contains newlines.
52-
:issue:`3043`
52+
:issue:`3043` :pr:`3126`
5353
- Add :class:`NoSuchCommand` exception with suggestions for misspelled
5454
commands. :issue:`3107` :pr:`3228`
5555
- Add ``click.get_pager_file`` for file-like access to an output

src/click/shell_completion.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,15 +421,16 @@ def get_completion_args(self) -> tuple[list[str], str]:
421421
return args, incomplete
422422

423423
def format_completion(self, item: CompletionItem) -> str:
424-
"""Format completion item for Fish shell.
425-
426-
Escapes newlines in both value and help text to prevent
427-
Fish shell parsing errors.
428-
429-
.. versionchanged:: 8.3
430-
Escape newlines in help text to fix completion errors
431-
with multi-line help strings.
432424
"""
425+
.. versionchanged:: 8.4
426+
Escape newlines in value and help to fix completion errors with
427+
multi-line help strings.
428+
"""
429+
# The fish completion script splits each response line on literal
430+
# newlines, so any newline in the value or help would corrupt the
431+
# frame. Replace them with the two-character escape "\n" so the text
432+
# round-trips through fish without breaking the format. The "_"
433+
# sentinel for missing help mirrors :class:`ZshComplete`.
433434
help_ = item.help or "_"
434435
value = item.value.replace("\n", r"\n")
435436
help_escaped = help_.replace("\n", r"\n")

0 commit comments

Comments
 (0)