From 7ed4dfbd2d301f9f6df9f73b4842c2aaf5d57a89 Mon Sep 17 00:00:00 2001 From: kerty Date: Sun, 23 Mar 2025 20:10:55 +0300 Subject: [PATCH] Ease condition for the execution of the right prompt Now, the right prompt will not be executed only if it is undefined `fish_right_prompt`. This allows the use of `read -p 'echo left' -R 'echo right'`. Also changes condition for use of `DEFAULT_PROMPT` for consistency. --- src/reader.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/reader.rs b/src/reader.rs index 9af88ed6e..319bf764a 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -4556,19 +4556,21 @@ fn exec_prompt(&mut self, full_prompt: bool) { // Historic compatibility hack. // If the left prompt function is deleted, then use a default prompt instead of // producing an error. - let prompt_cmd = if self.conf.left_prompt_cmd == LEFT_PROMPT_FUNCTION_NAME - && !function::exists(&self.conf.left_prompt_cmd, self.parser) + let prompt_cmd = if self.conf.left_prompt_cmd != LEFT_PROMPT_FUNCTION_NAME + || function::exists(&self.conf.left_prompt_cmd, self.parser) { - DEFAULT_PROMPT - } else { &self.conf.left_prompt_cmd + } else { + DEFAULT_PROMPT }; self.left_prompt_buff = join_strings(&self.exec_prompt_cmd(prompt_cmd), '\n'); } + // Don't execute the right prompt if it is undefined fish_right_prompt if !self.conf.right_prompt_cmd.is_empty() - && function::exists(&self.conf.right_prompt_cmd, self.parser) + && (self.conf.right_prompt_cmd != RIGHT_PROMPT_FUNCTION_NAME + || function::exists(&self.conf.right_prompt_cmd, self.parser)) { // Right prompt does not support multiple lines, so just concatenate all of them. self.right_prompt_buff =