diff --git a/src/alias_registry.hh b/src/alias_registry.hh index 4f1a472b..faf856d6 100644 --- a/src/alias_registry.hh +++ b/src/alias_registry.hh @@ -16,6 +16,11 @@ public: void remove_alias(const String& alias); StringView operator[](const String& name) const; + using AliasMap = UnorderedMap; + using iterator = AliasMap::const_iterator; + iterator begin() const { return m_aliases.begin(); } + iterator end() const { return m_aliases.end(); } + Vector aliases_for(StringView command) const; private: diff --git a/src/command_manager.cc b/src/command_manager.cc index e626ed6c..5d5920a2 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -567,9 +567,14 @@ Completions CommandManager::complete(const Context& context, { if (command.second.flags & CommandFlags::Hidden) continue; - if ( prefix_match(command.first, prefix)) + if (prefix_match(command.first, prefix)) 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()); return result; }