mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Clean up env_stack_t::pop
Use the new dispatch mechanism to reduce duplication
This commit is contained in:
parent
a4fe3c87ae
commit
11651dec7a
1 changed files with 9 additions and 14 deletions
23
src/env.cpp
23
src/env.cpp
|
@ -1191,24 +1191,19 @@ void env_stack_t::push(bool new_scope) { vars_stack().push(new_scope); }
|
||||||
void env_stack_t::pop() {
|
void env_stack_t::pop() {
|
||||||
auto &vars = vars_stack();
|
auto &vars = vars_stack();
|
||||||
auto old_node = vars.pop();
|
auto old_node = vars.pop();
|
||||||
if (old_node->contains_any_of(locale_variables)) {
|
|
||||||
init_locale(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (old_node->contains_any_of(curses_variables)) {
|
// Maybe exported variables have changed.
|
||||||
init_curses(*this);
|
if (old_node->exportv) {
|
||||||
}
|
// This node exported or unexported a variable.
|
||||||
|
vars.mark_changed_exported();
|
||||||
if (old_node->new_scope && (old_node->exportv || vars.local_scope_exports(old_node->next))) {
|
} else if (old_node->new_scope && vars.local_scope_exports(old_node->next)) {
|
||||||
|
// This node was a local scope, so it shadowed exports from its parent.
|
||||||
vars.mark_changed_exported();
|
vars.mark_changed_exported();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &entry_pair : old_node->env) {
|
// TODO: we would like to coalesce locale / curses changes, so that we only re-initialize once.
|
||||||
const env_var_t &var = entry_pair.second;
|
for (const auto &kv : old_node->env) {
|
||||||
if (var.exports()) {
|
env_dispatch_var_change(kv.first, *this);
|
||||||
vars.mark_changed_exported();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue