Always check for fish_right_prompt's existence

This would only check for fish_right_prompt at startup, so if one
wasn't defined then it would never accept one.

The "config" here is just the *name* of the function (which we never
change, so it wouldn't really be necessary, but whatever).

The one exception is the breakpoint, in those we don't run the right
prompt.

Fixes #7302.
This commit is contained in:
Fabian Homborg 2020-09-02 17:48:24 +02:00
parent 4d22ebf49c
commit b521ca4875

View File

@ -1205,6 +1205,7 @@ void reader_data_t::exec_prompt() {
} }
if (!conf.right_prompt_cmd.empty()) { if (!conf.right_prompt_cmd.empty()) {
if (function_exists(conf.right_prompt_cmd, parser())) {
// Status is ignored. // Status is ignored.
wcstring_list_t prompt_list; wcstring_list_t prompt_list;
exec_subshell(conf.right_prompt_cmd, parser(), prompt_list, false); exec_subshell(conf.right_prompt_cmd, parser(), prompt_list, false);
@ -1214,6 +1215,7 @@ void reader_data_t::exec_prompt() {
} }
} }
} }
}
// Write the screen title. Do not reset the cursor position: exec_prompt is called when there // Write the screen title. Do not reset the cursor position: exec_prompt is called when there
// may still be output on the line from the previous command (#2499) and we need our PROMPT_SP // may still be output on the line from the previous command (#2499) and we need our PROMPT_SP
@ -2510,15 +2512,12 @@ static int read_i(parser_t &parser) {
if (parser.libdata().is_breakpoint && function_exists(DEBUG_PROMPT_FUNCTION_NAME, parser)) { if (parser.libdata().is_breakpoint && function_exists(DEBUG_PROMPT_FUNCTION_NAME, parser)) {
conf.left_prompt_cmd = DEBUG_PROMPT_FUNCTION_NAME; conf.left_prompt_cmd = DEBUG_PROMPT_FUNCTION_NAME;
conf.right_prompt_cmd = wcstring{};
} else { } else {
conf.left_prompt_cmd = LEFT_PROMPT_FUNCTION_NAME; conf.left_prompt_cmd = LEFT_PROMPT_FUNCTION_NAME;
conf.right_prompt_cmd = RIGHT_PROMPT_FUNCTION_NAME;
} }
if (function_exists(RIGHT_PROMPT_FUNCTION_NAME, parser)) {
conf.right_prompt_cmd = RIGHT_PROMPT_FUNCTION_NAME;
} else {
conf.right_prompt_cmd = wcstring{};
}
std::shared_ptr<reader_data_t> data = std::shared_ptr<reader_data_t> data =
reader_push_ret(parser, history_session_id(parser.vars()), std::move(conf)); reader_push_ret(parser, history_session_id(parser.vars()), std::move(conf));