Fix incorrect first line checks in rendering

The right prompt was rendered even if scrolled.
The command line wasn't rendering on the first line, starting from 0 to the left prompt length. Steps to reproduce:
fish -C 'bind ctrl-g \'commandline $(printf %0"$(math $COLUMNS)"d0) $(seq $(math $LINES - 1))\''
# use ctrl-g
# observe that only one '0' is rendered
This commit is contained in:
kerty
2025-01-25 15:13:41 +03:00
committed by Johannes Altmanninger
parent e2c9969840
commit be95b176bc

View File

@@ -1149,8 +1149,8 @@ fn s_line(zelf: &Screen, i: usize) -> &Line {
// Output all lines.
for i in 0..zelf.desired.line_count() {
zelf.actual.create_line(i);
let start_pos = if i == 0 { left_prompt_width } else { 0 };
let is_first_line = i == 0 && !zelf.scrolled();
let start_pos = if is_first_line { left_prompt_width } else { 0 };
let mut current_width = 0;
let mut has_cleared_line = false;
@@ -1209,7 +1209,7 @@ fn s_line(zelf: &Screen, i: usize) -> &Line {
// If we're soft wrapped, and if we're going to change the first character of the next
// line, don't skip over the last two characters so that we maintain soft-wrapping.
skip_remaining = skip_remaining.min(screen_width.unwrap() - 2);
if i == 0 {
if is_first_line {
skip_remaining = skip_remaining.max(left_prompt_width);
}
}
@@ -1300,7 +1300,7 @@ fn s_line(zelf: &Screen, i: usize) -> &Line {
}
// Output any rprompt if this is the first line.
if i == 0 && right_prompt_width > 0 {
if is_first_line && right_prompt_width > 0 {
// Move the cursor to the beginning of the line first to be independent of the width.
// This helps prevent staircase effects if fish and the terminal disagree.
zelf.r#move(0, 0);