Skip to content

Commit 701b313

Browse files
authored
Fix completions for quoted/escaped parameters in Fish (#3013)
1 parent 3be1f33 commit 701b313

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

src/click/shell_completion.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ class FishComplete(ShellComplete):
405405
def get_completion_args(self) -> tuple[list[str], str]:
406406
cwords = split_arg_string(os.environ["COMP_WORDS"])
407407
incomplete = os.environ["COMP_CWORD"]
408+
if incomplete:
409+
incomplete = split_arg_string(incomplete)[0]
408410
args = cwords[1:]
409411

410412
# Fish stores the partial word in both COMP_WORDS and

tests/test_shell_completion.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ def test_full_source(runner, shell):
359359
("zsh", {"COMP_WORDS": "a b", "COMP_CWORD": "1"}, "plain\nb\nbee\n"),
360360
("fish", {"COMP_WORDS": "", "COMP_CWORD": ""}, "plain,a\nplain,b\tbee\n"),
361361
("fish", {"COMP_WORDS": "a b", "COMP_CWORD": "b"}, "plain,b\tbee\n"),
362+
("fish", {"COMP_WORDS": 'a "b', "COMP_CWORD": '"b'}, "plain,b\tbee\n"),
362363
],
363364
)
364365
@pytest.mark.usefixtures("_patch_for_completion")

0 commit comments

Comments
 (0)