Simplify function_info_t and function_data_t

Work towards cleaning up function definition. Migrate inherit_vars into
props and capture their values at the point of definition.
This commit is contained in:
ridiculousfish
2019-11-12 09:53:10 -08:00
parent b0cf94e3ba
commit b51edcfcac
5 changed files with 40 additions and 67 deletions

View File

@@ -213,15 +213,11 @@ static wcstring functions_def(const wcstring &name) {
}
// Output any inherited variables as `set -l` lines.
std::map<wcstring, env_var_t> inherit_vars = function_get_inherit_vars(name);
for (const auto &kv : inherit_vars) {
wcstring_list_t lst;
kv.second.to_list(lst);
for (const auto &kv : props->inherit_vars) {
// We don't know what indentation style the function uses,
// so we do what fish_indent would.
append_format(out, L"\n set -l %ls", kv.first.c_str());
for (const auto &arg : lst) {
for (const auto &arg : kv.second) {
wcstring earg = escape_string(arg, ESCAPE_ALL);
out.push_back(L' ');
out.append(earg);