mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-15 22:44:01 +00:00
Make the bind mode per-parser
Eliminates a use of principal_parser
This commit is contained in:
parent
671df14178
commit
ad35fb7457
2 changed files with 4 additions and 12 deletions
|
@ -161,17 +161,15 @@ static latch_t<std::vector<terminfo_mapping_t>> s_terminfo_mappings;
|
|||
static std::vector<terminfo_mapping_t> 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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue