Fix missing right prompt when left prompt ends with empty line

Reproduction:
fish -C '
    function fish_prompt
        echo left-prompt\n
    end
    function fish_right_prompt
        echo right-prompt
    end
'

This was caused by an off-by-one error in initial Screen.desired resizing
from commit 606802daa (Make ScreenData track multiline prompt, 2025-10-15).
This commit is contained in:
kerty
2025-10-19 19:07:25 +03:00
committed by Johannes Altmanninger
parent 9ccd6fb2d2
commit e7ad7e5cf6

View File

@@ -358,7 +358,7 @@ struct ScrolledCursor {
self.desired.cursor.y = layout.left_prompt_lines - 1;
self.desired.clear_lines();
self.desired.resize(self.desired.cursor.y);
self.desired.resize(layout.left_prompt_lines);
// Append spaces for the left prompt.
let prompt_offset = if pager.search_field_shown {
@@ -452,12 +452,11 @@ struct ScrolledCursor {
};
// Add an empty line if there are no lines or if the last line was soft wrapped (but not by autosuggestion).
if self.desired.line_datas.last().is_none_or(|line| {
line.len() == screen_width
&& (commandline.is_empty()
|| autosuggestion.is_empty()
|| !explicit_after_suggestion.is_empty())
}) {
if self.desired.line_datas.last().unwrap().len() == screen_width
&& (commandline.is_empty()
|| autosuggestion.is_empty()
|| !explicit_after_suggestion.is_empty())
{
self.desired.add_line();
}