From 4116829292ddcfe21da86654b0a6a2bd765816b9 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Wed, 29 Apr 2020 14:22:54 -0700 Subject: [PATCH] Do not issue clr_eos if we think the cursor will end up on its own line If we output text and end up in the last column, the sticky right edge will cause a clr_eos to erase the last character. Ensure this doesn't happen by not issuing clr_eos in that case. Fixes #6951 --- src/screen.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/screen.cpp b/src/screen.cpp index 91221be83..3697cec06 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -642,6 +642,7 @@ static void s_update(screen_t *scr, const wcstring &left_prompt, const wcstring const size_t lines_with_stuff = std::max(actual_lines_before_reset, scr->actual.line_count()); if (scr->desired.line_count() < lines_with_stuff) need_clear_screen = true; + // Output the left prompt if it has changed. if (left_prompt != scr->actual_left_prompt) { s_move(scr, 0, 0); s_write_str(scr, left_prompt.c_str()); @@ -649,6 +650,7 @@ static void s_update(screen_t *scr, const wcstring &left_prompt, const wcstring scr->actual.cursor.x = static_cast(left_prompt_width); } + // Output all lines. for (size_t i = 0; i < scr->desired.line_count(); i++) { const line_t &o_line = scr->desired.line(i); line_t &s_line = scr->actual.create_line(i); @@ -657,9 +659,13 @@ static void s_update(screen_t *scr, const wcstring &left_prompt, const wcstring bool has_cleared_line = false; // If this is the last line, maybe we should clear the screen. + // Don't issue clr_eos if we think the cursor will end up in the last column - see #6951. const bool should_clear_screen_this_line = - need_clear_screen && i + 1 == scr->desired.line_count() && clr_eos != nullptr; + need_clear_screen && i + 1 == scr->desired.line_count() && clr_eos != nullptr && + !(scr->desired.cursor.x == 0 && + scr->desired.cursor.y == static_cast(scr->desired.line_count())); + // skip_remaining is how many columns are unchanged on this line. // Note that skip_remaining is a width, not a character count. size_t skip_remaining = start_pos;