1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-24 20:13:00 +03:00

Deduplicate functions for completing alias names

"complete_alias_name" is a better name then "complete_alias" because
it's consistent with more similar names, which are:

	complete_client_name
	complete_command_name
	complete_module_name
	complete_option_name
	complete_register_name
	complete_scope
	complete_face
This commit is contained in:
Johannes Altmanninger 2022-07-19 10:21:43 +02:00
parent 57a98880ab
commit 1358fc3cef

View File

@ -205,14 +205,6 @@ static Completions complete_command_name(const Context& context, CompletionFlags
context, prefix.substr(0, cursor_pos));
}
static Completions complete_alias_name(const Context& context, CompletionFlags,
StringView prefix, ByteCount cursor_pos)
{
return { 0_byte, cursor_pos, complete(prefix, cursor_pos,
context.aliases().flatten_aliases()
| transform(&HashItem<String, String>::key)) };
}
struct ShellScriptCompleter
{
ShellScriptCompleter(String shell_script,
@ -1332,6 +1324,14 @@ const CommandDesc define_command_cmd = {
define_command
};
static Completions complete_alias_name(const Context& context, CompletionFlags,
StringView prefix, ByteCount cursor_pos)
{
return { 0_byte, cursor_pos, complete(prefix, cursor_pos,
context.aliases().flatten_aliases()
| transform(&HashItem<String, String>::key))};
}
const CommandDesc alias_cmd = {
"alias",
nullptr,
@ -1350,14 +1350,6 @@ const CommandDesc alias_cmd = {
}
};
static Completions complete_alias(const Context& context, CompletionFlags flags,
StringView 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,
@ -1366,7 +1358,7 @@ const CommandDesc unalias_cmd = {
ParameterDesc{{}, ParameterDesc::Flags::None, 2, 3},
CommandFlags::None,
CommandHelper{},
make_completer(complete_scope, complete_alias, complete_command_name),
make_completer(complete_scope, complete_alias_name, complete_command_name),
[](const ParametersParser& parser, Context& context, const ShellContext&)
{
AliasRegistry& aliases = get_scope(parser[0], context).aliases();