Small code tweaks regarding user modes

This commit is contained in:
Maxime Coste 2018-02-18 20:24:34 +11:00
parent f88195d2d9
commit fc60e29870
2 changed files with 3 additions and 3 deletions

View File

@ -1100,7 +1100,7 @@ const CommandDesc echo_cmd = {
} }
}; };
KeymapMode parse_keymap_mode(const String& str, const KeymapManager::UserModeList& user_modes) KeymapMode parse_keymap_mode(StringView str, const KeymapManager::UserModeList& user_modes)
{ {
if (prefix_match("normal", str)) return KeymapMode::Normal; if (prefix_match("normal", str)) return KeymapMode::Normal;
if (prefix_match("insert", str)) return KeymapMode::Insert; if (prefix_match("insert", str)) return KeymapMode::Insert;

View File

@ -51,7 +51,7 @@ KeymapManager::KeyList KeymapManager::get_mapped_keys(KeymapMode mode) const
return res; return res;
} }
void KeymapManager::add_user_mode(const String user_mode_name) void KeymapManager::add_user_mode(String user_mode_name)
{ {
auto modes = {"normal", "insert", "prompt", "menu", "goto", "view", "user", "object"}; auto modes = {"normal", "insert", "prompt", "menu", "goto", "view", "user", "object"};
if (contains(modes, user_mode_name)) if (contains(modes, user_mode_name))
@ -63,7 +63,7 @@ void KeymapManager::add_user_mode(const String user_mode_name)
if (contains_that(user_mode_name, [](char c){ return not isalnum(c); })) if (contains_that(user_mode_name, [](char c){ return not isalnum(c); }))
throw runtime_error(format("invalid mode name: '{}'", user_mode_name)); throw runtime_error(format("invalid mode name: '{}'", user_mode_name));
m_user_modes.push_back(user_mode_name); m_user_modes.push_back(std::move(user_mode_name));
} }
} }