Skip to content

Commit

Permalink
fixed (sub)command name completion pallets#1529
Browse files Browse the repository at this point in the history
  • Loading branch information
jkowalleck authored and kx-chen committed Aug 19, 2020
1 parent 1d6f93f commit 4d76825
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/click/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ def sort_key(item):


def _get_visible_commands(ctx, incomplete):
for c in ctx.command.list_commands(ctx):
if c.startswith(incomplete):
command = ctx.command.get_command(ctx, c)
for name in ctx.command.list_commands(ctx):
if name.startswith(incomplete):
command = ctx.command.get_command(ctx, name)
if not command.hidden:
yield command
yield name, command


class ParameterSource:
Expand Down Expand Up @@ -765,14 +765,14 @@ def shell_complete(self, ctx, all_args, incomplete):
ctx = ctx.parent
if isinstance(ctx.command, MultiCommand) and ctx.command.chain:
remaining_commands = [
c
for c in _get_visible_commands(ctx, incomplete)
if c.name not in ctx.protected_args
(name, command)
for name, command in _get_visible_commands(ctx, incomplete)
if name not in ctx.protected_args
]
results.extend(
[
("plain", c.name, c.get_short_help_str())
for c in remaining_commands
("plain", name, command.get_short_help_str())
for name, command in remaining_commands
]
)
return results
Expand Down Expand Up @@ -1420,8 +1420,8 @@ def shell_complete(self, ctx, all_args, incomplete):
results = []
results.extend(
[
("plain", c.name, c.get_short_help_str())
for c in _get_visible_commands(ctx, incomplete)
("plain", name, command.get_short_help_str())
for name, command in _get_visible_commands(ctx, incomplete)
]
)
results.extend(BaseCommand.shell_complete(self, ctx, all_args, incomplete))
Expand Down

0 comments on commit 4d76825

Please sign in to comment.