mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-29 10:31:14 -03:00
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:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user