From 098f61468096609337b1670bb9ba82a032eff48c Mon Sep 17 00:00:00 2001 From: Saipraneeth <2506664+msaipraneeth@users.noreply.github.com> Date: Tue, 3 Dec 2024 07:27:14 +0000 Subject: [PATCH 1/7] break the loop on identifying last option --- src/click/shell_completion.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/click/shell_completion.py b/src/click/shell_completion.py index c8655b12a..03281edd1 100644 --- a/src/click/shell_completion.py +++ b/src/click/shell_completion.py @@ -525,6 +525,7 @@ def _is_incomplete_option(ctx: Context, args: list[str], param: Parameter) -> bo if _start_of_option(ctx, arg): last_option = arg + break return last_option is not None and last_option in param.opts From 3c64403946a9471130d85a912a7324ec7cb40dfa Mon Sep 17 00:00:00 2001 From: saipraneeth <2506664+msaipraneeth@users.noreply.github.com> Date: Wed, 4 Dec 2024 07:14:17 +0000 Subject: [PATCH 2/7] add test for flag with naargs option auto completion --- tests/test_shell_completion.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_shell_completion.py b/tests/test_shell_completion.py index 3511f0743..830dc92da 100644 --- a/tests/test_shell_completion.py +++ b/tests/test_shell_completion.py @@ -188,6 +188,19 @@ def test_option_flag(): assert _get_words(cli, ["--on"], "a") == ["a1", "a2"] +def test_flag_option_with_nargs_option(): + cli = Command( + "cli", + add_help_option=False, + params=[ + Argument(["a"], type=Choice(["a1", "a2", "b"])), + Option(["--flag"], is_flag=True), + Option(["-c"], type=Choice(["p", "q"]), nargs=2), + ], + ) + assert _get_words(cli, ["a1", "--flag", "-c"], "") == ["p", "q"] + + def test_option_custom(): def custom(ctx, param, incomplete): return [incomplete.upper()] From 7fc377138a1d61c71c5bec2048ec6bb6de1015aa Mon Sep 17 00:00:00 2001 From: saipraneeth <2506664+msaipraneeth@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:54:41 +0000 Subject: [PATCH 3/7] update change log --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 057d700df..0c1446d0e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -112,6 +112,8 @@ Unreleased :issue:`2632` - Fix ``click.echo(color=...)`` passing ``color`` to coloroma so it can be forced on Windows. :issue:`2606`. +- show correct auto complete value for nargs option in combination with + flag option :issue:`2813` Version 8.1.7 From 20fe0caaaabaaae7147045ae8244c69e0b504dba Mon Sep 17 00:00:00 2001 From: Saipraneeth <2506664+msaipraneeth@users.noreply.github.com> Date: Thu, 7 Aug 2025 05:50:43 +0530 Subject: [PATCH 4/7] Update CHANGES.rst --- CHANGES.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index a2f60d68f..1db611fd2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,5 +1,14 @@ .. currentmodule:: click +Version 8.2.x + +------------- + +Unreleased + +- show correct auto complete value for nargs option in combination with +flag option :issue:`2813` + Version 8.2.2 ------------- From 83ece01c758fd70394c07d76cff517f82a7a953f Mon Sep 17 00:00:00 2001 From: Saipraneeth <2506664+msaipraneeth@users.noreply.github.com> Date: Thu, 7 Aug 2025 05:51:35 +0530 Subject: [PATCH 5/7] fix formatting CHANGES.rst --- CHANGES.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 1db611fd2..a31842f39 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,8 +6,7 @@ Version 8.2.x Unreleased -- show correct auto complete value for nargs option in combination with -flag option :issue:`2813` +- show correct auto complete value for nargs option in combination with flag option :issue:`2813` Version 8.2.2 ------------- From 3cb95557c45bcb15c0ebb1e557e3fe45a2589b1c Mon Sep 17 00:00:00 2001 From: Saipraneeth <2506664+msaipraneeth@users.noreply.github.com> Date: Thu, 7 Aug 2025 05:52:23 +0530 Subject: [PATCH 6/7] Update CHANGES.rst --- CHANGES.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index a31842f39..bbe26f1c5 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,7 +1,6 @@ .. currentmodule:: click Version 8.2.x - ------------- Unreleased From c03b461e6713a53849134fe186feeea0efd1244d Mon Sep 17 00:00:00 2001 From: Saipraneeth <2506664+msaipraneeth@users.noreply.github.com> Date: Thu, 7 Aug 2025 05:56:14 +0530 Subject: [PATCH 7/7] remove trailing space in CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index bbe26f1c5..c2e019da3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,7 +3,7 @@ Version 8.2.x ------------- -Unreleased +Unreleased - show correct auto complete value for nargs option in combination with flag option :issue:`2813`