summaryrefslogtreecommitdiff
path: root/src/command_manager.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2020-07-18 14:29:44 +1000
committerMaxime Coste <mawww@kakoune.org>2020-07-19 12:54:41 +1000
commit5df8073c3c4213075d1c0ee6267cc58848b86721 (patch)
tree034ca45c78357a748d094d59b884f66cb1e82c7e /src/command_manager.cc
parentd4962d94ce36870091d159b93daa4dd07441810c (diff)
Code style tweaks
Diffstat (limited to 'src/command_manager.cc')
-rw-r--r--src/command_manager.cc15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc
index c6e52992..a66134f5 100644
--- a/src/command_manager.cc
+++ b/src/command_manager.cc
@@ -487,13 +487,10 @@ struct command_not_found : runtime_error
: runtime_error(format("no such command: '{}'", name)) {}
};
-CommandManager::CommandMap::const_iterator
-CommandManager::find_command(const Context& context, StringView name) const
+StringView resolve_alias(const Context& context, StringView name)
{
auto alias = context.aliases()[name];
- StringView cmd_name = alias.empty() ? name : alias;
-
- return m_commands.find(cmd_name);
+ return alias.empty() ? name : alias;
}
void CommandManager::execute_single_command(CommandParameters params,
@@ -512,7 +509,7 @@ void CommandManager::execute_single_command(CommandParameters params,
auto pop_cmd = on_scope_end([this] { --m_command_depth; });
ParameterList param_view(params.begin()+1, params.end());
- auto command_it = find_command(context, params[0]);
+ auto command_it = m_commands.find(resolve_alias(context, params[0]));
if (command_it == m_commands.end())
throw command_not_found(params[0]);
@@ -587,7 +584,7 @@ Optional<CommandInfo> CommandManager::command_info(const Context& context, Strin
tokens.front().type != Token::Type::RawQuoted))
return {};
- auto cmd = find_command(context, tokens.front().content);
+ auto cmd = m_commands.find(resolve_alias(context, tokens.front().content));
if (cmd == m_commands.end())
return {};
@@ -729,7 +726,7 @@ Completions CommandManager::complete(const Context& context,
flags |= CompletionFlags::Start;
}
- auto command_it = find_command(context, command_name);
+ auto command_it = m_commands.find(resolve_alias(context, command_name));
if (command_it == m_commands.end())
return Completions{};
@@ -786,7 +783,7 @@ Completions CommandManager::complete(const Context& context,
flags |= CompletionFlags::Start;
}
- auto command_it = find_command(context, command_name);
+ auto command_it = m_commands.find(resolve_alias(context, command_name));
if (command_it != m_commands.end() and command_it->value.completer)
return command_it->value.completer(
context, flags, params.subrange(1),