Repaint-mode to reexecute the rest if mode-prompt output is empty

We previously checked if fish_mode_prompt existed as a function, but
that's a bad change for those who already set it to an empty function
to have a mode display elsewhere.
This commit is contained in:
Fabian Homborg
2019-05-14 13:07:04 +02:00
parent 005e6f2ab8
commit 0aead5caf8
2 changed files with 9 additions and 4 deletions

View File

@@ -2483,18 +2483,21 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
break;
}
case rl::repaint_mode: {
// Repaint the mode-prompt only if it exists.
// Repaint the mode-prompt only if possible.
// This is an optimization basically exclusively for vi-mode, since the prompt
// may sometimes take a while but when switching the mode all we care about is the
// mode-prompt.
if (function_exists(MODE_PROMPT_FUNCTION_NAME, parser())) {
exec_mode_prompt();
//
// Because some users set `fish_mode_prompt` to an empty function and display the mode elsewhere,
// we detect if the mode output is empty.
exec_mode_prompt();
if(!mode_prompt_buff.empty()) {
s_reset(&screen, screen_reset_current_line_and_prompt);
screen_reset_needed = false;
repaint();
break;
}
// If it doesn't exist, we repaint as normal.
// Else we repaint as normal.
/* fallthrough */
}
case rl::force_repaint: