Fix glitch rendering commandline that overflows screen size

If the first physical line in the command line overflows the screen,
the cursor will be wrong and we'll fail to clear the prompt without
a manual ctrl-l.  Let's fix that, and also don't print the OSC 133
marker in this case.

Currently, when we are scrolled, the first line on the screen still
gets an indentation that would normally be filled by the prompt.
This happens even for soft-wrapped lines, so they might be
torn apart in weird ways here.

In future, we might paint the prompt here.  If not, the current
behavior for soft-wrapped lines is debatable but its' not super
important to fix. The main goal is to first get rid of glitches in
these edge cases.
This commit is contained in:
Johannes Altmanninger 2024-10-27 06:00:18 +01:00
parent c155acd004
commit adfa87d141

View File

@ -904,8 +904,14 @@ impl Screen {
let term = term.as_ref();
// Output the left prompt if it has changed.
let visible_left_prompt = if scrolled { L!("") } else { left_prompt };
if visible_left_prompt != zelf.actual_left_prompt {
if scrolled {
zelf.r#move(0, 0);
zelf.outp
.borrow_mut()
.tputs_if_some(&term.and_then(|term| term.clr_eol.as_ref()));
zelf.actual_left_prompt.clear();
zelf.actual.cursor.x = 0;
} else if left_prompt != zelf.actual_left_prompt {
zelf.r#move(0, 0);
let mut start = 0;
let osc_133_prompt_start =
@ -920,11 +926,11 @@ impl Screen {
if i == 0 {
osc_133_prompt_start(&mut zelf);
}
zelf.write_str(&visible_left_prompt[start..=line_break]);
zelf.write_str(&left_prompt[start..=line_break]);
start = line_break + 1;
}
zelf.write_str(&visible_left_prompt[start..]);
zelf.actual_left_prompt = visible_left_prompt.to_owned();
zelf.write_str(&left_prompt[start..]);
zelf.actual_left_prompt = left_prompt.to_owned();
zelf.actual.cursor.x = left_prompt_width;
}