From ad35fb7457a97555714168925d1f14397a271d6d Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 2 Jun 2019 16:57:52 -0700 Subject: [PATCH] Make the bind mode per-parser Eliminates a use of principal_parser --- src/input.cpp | 10 ++++------ src/input.h | 6 ------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index 530cbe450..fad6d9c77 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -161,17 +161,15 @@ static latch_t> s_terminfo_mappings; static std::vector create_input_terminfo(); /// Return the current bind mode. -wcstring input_get_bind_mode(const environment_t &vars) { +static wcstring input_get_bind_mode(const environment_t &vars) { auto mode = vars.get(FISH_BIND_MODE_VAR); return mode ? mode->as_string() : DEFAULT_BIND_MODE; } /// Set the current bind mode. -void input_set_bind_mode(const wcstring &bm) { +static void input_set_bind_mode(env_stack_t &vars, const wcstring &bm) { // Only set this if it differs to not execute variable handlers all the time. // modes may not be empty - empty is a sentinel value meaning to not change the mode - ASSERT_IS_MAIN_THREAD(); - auto &vars = parser_t::principal_parser().vars(); assert(!bm.empty()); if (input_get_bind_mode(vars) != bm) { vars.set_one(FISH_BIND_MODE_VAR, ENV_GLOBAL, bm); @@ -339,7 +337,7 @@ void inputter_t::mapping_execute(const input_mapping_t &m, bool allow_commands) // !has_functions && !has_commands: only set bind mode if (!has_commands && !has_functions) { - if (!m.sets_mode.empty()) input_set_bind_mode(m.sets_mode); + if (!m.sets_mode.empty()) input_set_bind_mode(parser_->vars(), m.sets_mode); return; } @@ -378,7 +376,7 @@ void inputter_t::mapping_execute(const input_mapping_t &m, bool allow_commands) } // Empty bind mode indicates to not reset the mode (#2871) - if (!m.sets_mode.empty()) input_set_bind_mode(m.sets_mode); + if (!m.sets_mode.empty()) input_set_bind_mode(parser_->vars(), m.sets_mode); } /// Try reading the specified function mapping. diff --git a/src/input.h b/src/input.h index b5fb40ca1..d3a4c2160 100644 --- a/src/input.h +++ b/src/input.h @@ -101,12 +101,6 @@ bool input_mapping_erase(const wcstring &sequence, const wcstring &mode = DEFAUL bool input_mapping_get(const wcstring &sequence, const wcstring &mode, wcstring_list_t *out_cmds, bool user, wcstring *out_new_mode); -/// Return the current bind mode. -wcstring input_get_bind_mode(const environment_t &vars); - -/// Set the current bind mode. -void input_set_bind_mode(const wcstring &bind_mode); - /// Sets the return status of the most recently executed input function. void input_function_set_status(bool status);