From 3a36490ef152171631dd5a307f00adffde4e18e9 Mon Sep 17 00:00:00 2001 From: Delapouite Date: Mon, 8 Oct 2018 22:07:13 +0200 Subject: [PATCH] Add alias completer to unalias command --- src/commands.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/commands.cc b/src/commands.cc index 0e7ccf97..15658ede 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1141,6 +1141,14 @@ const CommandDesc alias_cmd = { } }; +static Completions complete_alias(const Context& context, CompletionFlags flags, + const String& prefix, ByteCount cursor_pos) +{ + return {0_byte, cursor_pos, + complete(prefix, cursor_pos, context.aliases().flatten_aliases() | + transform([](auto& entry) -> const String& { return entry.key; }))}; +} + const CommandDesc unalias_cmd = { "unalias", nullptr, @@ -1149,7 +1157,7 @@ const CommandDesc unalias_cmd = { ParameterDesc{{}, ParameterDesc::Flags::None, 2, 3}, CommandFlags::None, CommandHelper{}, - make_completer(complete_scope, complete_nothing, complete_command_name), + make_completer(complete_scope, complete_alias, complete_command_name), [](const ParametersParser& parser, Context& context, const ShellContext&) { AliasRegistry& aliases = get_scope(parser[0], context).aliases();