From 99dd6d7394576d1e6e9600efef8a8375d50ba6e1 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Mon, 1 Apr 2019 16:04:14 +0200 Subject: [PATCH] Let repaint-mode act like a repaint if no fish_mode_prompt exists Otherwise I'm pretty sure we'd get complaints from people who use a mode-indicator elsewhere in their prompts. --- sphinx_doc_src/cmds/bind.rst | 2 +- src/reader.cpp | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sphinx_doc_src/cmds/bind.rst b/sphinx_doc_src/cmds/bind.rst index 3455053d2..394bb42f1 100644 --- a/sphinx_doc_src/cmds/bind.rst +++ b/sphinx_doc_src/cmds/bind.rst @@ -138,7 +138,7 @@ The following special input functions are available: - ``repaint`` reexecutes the prompt functions and redraws the prompt. Multiple successive repaints are coalesced. -- ``repaint-mode`` reexecutes the fish_mode_prompt function and redraws the prompt. This is useful for vi-mode. +- ``repaint-mode`` reexecutes the fish_mode_prompt function and redraws the prompt. This is useful for vi-mode. If no fish_mode_prompt exists, it acts like a normal repaint. - ``suppress-autosuggestion``, remove the current autosuggestion diff --git a/src/reader.cpp b/src/reader.cpp index 04f4c8668..acdd9ad3f 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -2514,11 +2514,15 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat // Repaint the mode-prompt only if it exists. // 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. - exec_mode_prompt(); - s_reset(&screen, screen_reset_current_line_and_prompt); - screen_reset_needed = false; - repaint(); - break; + if (function_exists(MODE_PROMPT_FUNCTION_NAME)) { + exec_mode_prompt(); + s_reset(&screen, screen_reset_current_line_and_prompt); + screen_reset_needed = false; + repaint(); + break; + } + // If it doesn't exist, we repaint as normal. + /* fallthrough */ } case rl::force_repaint: case rl::repaint: {