mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 02:31:18 -03:00
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:
@@ -13,6 +13,8 @@ Description
|
|||||||
The default ``fish_mode_prompt`` function will output indicators about the current Vi editor mode displayed to the left of the regular prompt. Define your own function to customize the appearance of the mode indicator. You can also define an empty ``fish_mode_prompt`` function to remove the Vi mode indicators. The ``$fish_bind_mode variable`` can be used to determine the current mode. It
|
The default ``fish_mode_prompt`` function will output indicators about the current Vi editor mode displayed to the left of the regular prompt. Define your own function to customize the appearance of the mode indicator. You can also define an empty ``fish_mode_prompt`` function to remove the Vi mode indicators. The ``$fish_bind_mode variable`` can be used to determine the current mode. It
|
||||||
will be one of ``default``, ``insert``, ``replace_one``, or ``visual``.
|
will be one of ``default``, ``insert``, ``replace_one``, or ``visual``.
|
||||||
|
|
||||||
|
fish_mode_prompt will be executed when the vi mode changes. If it produces any output, it is displayed and used. If it does not, the other prompt functions (:ref:`fish_prompt <cmd-fish_prompt>` and :ref:`fish_right_prompt <cmd-fish_right_prompt>`) will be executed as well in case they contain a mode display.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|||||||
@@ -2483,18 +2483,21 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case rl::repaint_mode: {
|
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
|
// 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
|
// may sometimes take a while but when switching the mode all we care about is the
|
||||||
// mode-prompt.
|
// 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);
|
s_reset(&screen, screen_reset_current_line_and_prompt);
|
||||||
screen_reset_needed = false;
|
screen_reset_needed = false;
|
||||||
repaint();
|
repaint();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// If it doesn't exist, we repaint as normal.
|
// Else we repaint as normal.
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
}
|
}
|
||||||
case rl::force_repaint:
|
case rl::force_repaint:
|
||||||
|
|||||||
Reference in New Issue
Block a user