From 10d91b0249f57a5269ee5e1c0517da095fe3c820 Mon Sep 17 00:00:00 2001
From: Fabian Boehm <FHomborg@gmail.com>
Date: Sat, 30 Sep 2023 15:27:37 +0200
Subject: [PATCH] screen: Unset color at the end of a line even without clr_eol

This is a sensible thing to do, and fixes some cases where we're
state-dependent.

E.g. this fixes the case in the pager where some things are bold and
some aren't, because that bolding is (rather awkwardly) implicitly
triggered when we have a background, and so we don't notice we need to
re-do that bolding after we moved to the next line because we think we
still have the same color.

Fixes #9617
---
 src/screen.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/screen.cpp b/src/screen.cpp
index 7e6dcc128..ea305c0dd 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -883,8 +883,12 @@ void screen_t::update(const wcstring &left_prompt, const wcstring &right_prompt,
                 clear_remainder = prev_width > current_width;
             }
         }
+
+        // We unset the color even if we don't clear the line.
+        // This means that we switch background correctly on the next,
+        // including our weird implicit bolding.
+        set_color(highlight_spec_t{});
         if (clear_remainder && clr_eol) {
-            set_color(highlight_spec_t{});
             this->move(current_width, static_cast<int>(i));
             this->write_mbs(clr_eol);
         }