Try to rationalize universal variable syncing

Prior to this commit, setting a universal variable may trigger syncing
against the file which will modify other universal variables. But if we
want to support multiple environments we need the parser to decide when to
sync uvars. Shift the decision of when to sync to the parser itself. When a
universal variable is modified, now we just set a flag and it's up to the
(main) parser when to pick it up. This is hopefully just a refactoring with
no user-visible changes.
This commit is contained in:
ridiculousfish
2022-03-27 18:59:34 -07:00
parent 9c53033f54
commit f45e16e59d
12 changed files with 75 additions and 49 deletions

View File

@@ -194,19 +194,6 @@ void env_dispatch_var_change(const wcstring &key, env_stack_t &vars) {
s_var_dispatch_table->dispatch(key, vars);
}
// Trigger events due to a universal variable changing.
void env_universal_callbacks(env_stack_t *stack, const callback_data_list_t &callbacks) {
for (const callback_data_t &cb : callbacks) {
env_dispatch_var_change(cb.key, *stack);
// TODO: eliminate this principal_parser. Need to rationalize how multiple threads work
// here.
event_t evt =
cb.is_erase() ? event_t::variable_erase(cb.key) : event_t::variable_set(cb.key);
event_fire(parser_t::principal_parser(), evt);
}
}
static void handle_fish_term_change(const env_stack_t &vars) {
update_fish_color_support(vars);
reader_schedule_prompt_repaint();