From 87a9a60442720dde3793a52e840b56d936b5f183 Mon Sep 17 00:00:00 2001 From: Ethan Wu Date: Mon, 8 Jul 2024 22:41:29 -0700 Subject: [PATCH] Fix themes kitten not displaying colors in narrow windows The themes kitten used the truncated color name when formatting the colors themselves, which leads to broken coloring when the window is narrow enough to cause truncation to occur. --- kittens/themes/ui.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kittens/themes/ui.go b/kittens/themes/ui.go index f552e9862..c453e5344 100644 --- a/kittens/themes/ui.go +++ b/kittens/themes/ui.go @@ -451,10 +451,11 @@ func (self *handler) draw_theme_demo() { if intense { s = "bright-" + s } - if len(s) > trunc { - s = s[:trunc] + sTrunc := s + if len(sTrunc) > trunc { + sTrunc = sTrunc[:trunc] } - buf.WriteString(self.lp.SprintStyled("fg="+s, s)) + buf.WriteString(self.lp.SprintStyled("fg="+s, sTrunc)) buf.WriteString(" ") } text := strings.TrimSpace(buf.String())