From 2e119813e11e99e8cb95d257198b9e5023f02701 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Tue, 16 Apr 2019 22:27:01 -0700 Subject: [PATCH] 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(). --- src/complete.cpp | 2 +- src/expand.cpp | 4 +--- src/expand.h | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/complete.cpp b/src/complete.cpp index d4091855d..37929e372 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -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 abbrs = get_abbreviations(); + std::map abbrs = get_abbreviations(vars); std::vector possible_comp; possible_comp.reserve(abbrs.size()); for (const auto &kv : abbrs) { diff --git a/src/expand.cpp b/src/expand.cpp index 4beb8ede8..aa91f3d4b 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -1197,9 +1197,8 @@ maybe_t expand_abbreviation(const wcstring &src) { return expand_abbreviation(src, env_stack_t::principal()); } -std::map get_abbreviations() { +std::map 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 result; @@ -1210,4 +1209,3 @@ std::map get_abbreviations() { } return result; } - diff --git a/src/expand.h b/src/expand.h index 2386f45c4..84500c37e 100644 --- a/src/expand.h +++ b/src/expand.h @@ -165,7 +165,7 @@ maybe_t expand_abbreviation(const wcstring &src, const environment_t & maybe_t expand_abbreviation(const wcstring &src); /// \return a snapshot of all abbreviations as a map abbreviation->expansion. -std::map get_abbreviations(); +std::map get_abbreviations(const environment_t &vars); // Terrible hacks bool fish_xdm_login_hack_hack_hack_hack(std::vector *cmds, int argc,