get_abbreviations to accept an environment_t

Now that we don't have dorky snapshotting, thread an dnvironment_t through
get_abbreviations. Removes a usage of env_stack_t::principal().
This commit is contained in:
ridiculousfish
2019-04-16 22:27:01 -07:00
parent 7e514d2aa5
commit 2e119813e1
3 changed files with 3 additions and 5 deletions

View File

@@ -707,7 +707,7 @@ void completer_t::complete_cmd(const wcstring &str_cmd, bool use_function, bool
}
void completer_t::complete_abbr(const wcstring &cmd) {
std::map<wcstring, wcstring> abbrs = get_abbreviations();
std::map<wcstring, wcstring> abbrs = get_abbreviations(vars);
std::vector<completion_t> possible_comp;
possible_comp.reserve(abbrs.size());
for (const auto &kv : abbrs) {

View File

@@ -1197,9 +1197,8 @@ maybe_t<wcstring> expand_abbreviation(const wcstring &src) {
return expand_abbreviation(src, env_stack_t::principal());
}
std::map<wcstring, wcstring> get_abbreviations() {
std::map<wcstring, wcstring> get_abbreviations(const environment_t &vars) {
// TODO: try to make this cheaper
const auto &vars = env_stack_t::principal();
const size_t fish_abbr_len = std::wcslen(L"_fish_abbr_");
auto names = vars.get_names(0);
std::map<wcstring, wcstring> result;
@@ -1210,4 +1209,3 @@ std::map<wcstring, wcstring> get_abbreviations() {
}
return result;
}

View File

@@ -165,7 +165,7 @@ maybe_t<wcstring> expand_abbreviation(const wcstring &src, const environment_t &
maybe_t<wcstring> expand_abbreviation(const wcstring &src);
/// \return a snapshot of all abbreviations as a map abbreviation->expansion.
std::map<wcstring, wcstring> get_abbreviations();
std::map<wcstring, wcstring> get_abbreviations(const environment_t &vars);
// Terrible hacks
bool fish_xdm_login_hack_hack_hack_hack(std::vector<std::string> *cmds, int argc,