diff options
| author | Maxime Coste <mawww@kakoune.org> | 2016-12-23 16:23:31 +0000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2016-12-23 16:23:31 +0000 |
| commit | d17bed9b80183bb80ae560200d08bacfaac679c2 (patch) | |
| tree | 0855c46ed2372a216b407257c514ccca88d06e1f /src/command_manager.cc | |
| parent | 62df6dbb46ce00be1031e907d222116864431888 (diff) | |
Display the command prompt in error face when the command is not found
Fixes #1021
Diffstat (limited to 'src/command_manager.cc')
| -rw-r--r-- | src/command_manager.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc index d5307032..e8d1158a 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -479,7 +479,7 @@ void CommandManager::execute(StringView command_line, execute_single_command(params, context, shell_context, command_coord); } -CommandInfo CommandManager::command_info(const Context& context, StringView command_line) const +Optional<CommandInfo> CommandManager::command_info(const Context& context, StringView command_line) const { TokenList tokens = parse<false>(command_line); size_t cmd_idx = 0; @@ -489,19 +489,19 @@ CommandInfo CommandManager::command_info(const Context& context, StringView comm cmd_idx = i+1; } - CommandInfo res; if (cmd_idx == tokens.size() or (tokens[cmd_idx].type() != Token::Type::Raw and tokens[cmd_idx].type() != Token::Type::RawQuoted)) - return res; + return {}; auto cmd = find_command(context, tokens[cmd_idx].content()); if (cmd == m_commands.end()) - return res; + return {}; - res.first = cmd->first; + CommandInfo res; + res.name = cmd->first; if (not cmd->second.docstring.empty()) - res.second += cmd->second.docstring + "\n"; + res.info += cmd->second.docstring + "\n"; if (cmd->second.helper) { @@ -520,7 +520,7 @@ CommandInfo CommandManager::command_info(const Context& context, StringView comm { if (helpstr.back() != '\n') helpstr += '\n'; - res.second += helpstr; + res.info += helpstr; } } @@ -528,14 +528,14 @@ CommandInfo CommandManager::command_info(const Context& context, StringView comm for (auto& alias : context.aliases().aliases_for(cmd->first)) aliases += " " + alias; if (not aliases.empty()) - res.second += "Aliases:" + aliases + "\n"; + res.info += "Aliases:" + aliases + "\n"; auto& switches = cmd->second.param_desc.switches; if (not switches.empty()) { - res.second += "Switches:\n"; - res.second += generate_switches_doc(switches); + res.info += "Switches:\n"; + res.info += generate_switches_doc(switches); } return res; |
