mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 14:01:20 -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) {
|
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;
|
std::vector<completion_t> possible_comp;
|
||||||
possible_comp.reserve(abbrs.size());
|
possible_comp.reserve(abbrs.size());
|
||||||
for (const auto &kv : abbrs) {
|
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());
|
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
|
// TODO: try to make this cheaper
|
||||||
const auto &vars = env_stack_t::principal();
|
|
||||||
const size_t fish_abbr_len = std::wcslen(L"_fish_abbr_");
|
const size_t fish_abbr_len = std::wcslen(L"_fish_abbr_");
|
||||||
auto names = vars.get_names(0);
|
auto names = vars.get_names(0);
|
||||||
std::map<wcstring, wcstring> result;
|
std::map<wcstring, wcstring> result;
|
||||||
@@ -1210,4 +1209,3 @@ std::map<wcstring, wcstring> get_abbreviations() {
|
|||||||
}
|
}
|
||||||
return result;
|
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);
|
maybe_t<wcstring> expand_abbreviation(const wcstring &src);
|
||||||
|
|
||||||
/// \return a snapshot of all abbreviations as a map abbreviation->expansion.
|
/// \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
|
// Terrible hacks
|
||||||
bool fish_xdm_login_hack_hack_hack_hack(std::vector<std::string> *cmds, int argc,
|
bool fish_xdm_login_hack_hack_hack_hack(std::vector<std::string> *cmds, int argc,
|
||||||
|
|||||||
Reference in New Issue
Block a user