Complete aliases in command prompt

This commit is contained in:
Maxime Coste 2015-09-06 18:09:32 +01:00
parent a45876124b
commit 30ad9a0475
2 changed files with 11 additions and 1 deletions

View File

@ -16,6 +16,11 @@ public:
void remove_alias(const String& alias); void remove_alias(const String& alias);
StringView operator[](const String& name) const; StringView operator[](const String& name) const;
using AliasMap = UnorderedMap<String, String, MemoryDomain::Aliases>;
using iterator = AliasMap::const_iterator;
iterator begin() const { return m_aliases.begin(); }
iterator end() const { return m_aliases.end(); }
Vector<StringView> aliases_for(StringView command) const; Vector<StringView> aliases_for(StringView command) const;
private: private:

View File

@ -570,6 +570,11 @@ Completions CommandManager::complete(const Context& context,
if (prefix_match(command.first, prefix)) if (prefix_match(command.first, prefix))
result.candidates.push_back(command.first); result.candidates.push_back(command.first);
} }
for (auto& alias : context.aliases())
{
if (prefix_match(alias.first, prefix))
result.candidates.push_back(alias.first);
}
std::sort(result.candidates.begin(), result.candidates.end()); std::sort(result.candidates.begin(), result.candidates.end());
return result; return result;
} }