From c236214c2906d2a67ea2d1d8dc5ecb701a871a8c Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 26 Sep 2026 14:42:57 +0200 Subject: [PATCH] Let strikethrough work in the theme colors that gocui draws Config.md lists strikethrough as a modifier for theme colors, but only GetTextStyle knows it. GetGocuiStyle turns an unknown name into white, and white OR-ed with a palette color is white. So if you set a border color to [red, strikethrough], you get a white border without strikethrough. The same goes for the parts of the selected line, options text and default text colors that gocui draws. Co-Authored-By: Claude Opus 5.5 (1M context) --- pkg/theme/gocui.go | 25 +++++++++++++------------ pkg/theme/gocui_test.go | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 pkg/theme/gocui_test.go diff --git a/pkg/theme/gocui.go b/pkg/theme/gocui.go index 6d10f8666..101f1d889 100644 --- a/pkg/theme/gocui.go +++ b/pkg/theme/gocui.go @@ -7,18 +7,19 @@ import ( ) var gocuiColorMap = map[string]gocui.Attribute{ - "default": gocui.ColorDefault, - "black": gocui.ColorBlack, - "red": gocui.ColorRed, - "green": gocui.ColorGreen, - "yellow": gocui.ColorYellow, - "blue": gocui.ColorBlue, - "magenta": gocui.ColorMagenta, - "cyan": gocui.ColorCyan, - "white": gocui.ColorWhite, - "bold": gocui.AttrBold, - "reverse": gocui.AttrReverse, - "underline": gocui.AttrUnderline, + "default": gocui.ColorDefault, + "black": gocui.ColorBlack, + "red": gocui.ColorRed, + "green": gocui.ColorGreen, + "yellow": gocui.ColorYellow, + "blue": gocui.ColorBlue, + "magenta": gocui.ColorMagenta, + "cyan": gocui.ColorCyan, + "white": gocui.ColorWhite, + "bold": gocui.AttrBold, + "reverse": gocui.AttrReverse, + "underline": gocui.AttrUnderline, + "strikethrough": gocui.AttrStrikeThrough, } // GetGocuiAttribute gets the gocui color attribute from the string diff --git a/pkg/theme/gocui_test.go b/pkg/theme/gocui_test.go new file mode 100644 index 000000000..7610c95d5 --- /dev/null +++ b/pkg/theme/gocui_test.go @@ -0,0 +1,38 @@ +package theme + +import ( + "testing" + + "github.com/jesseduffield/lazygit/pkg/gocui" + "github.com/stretchr/testify/assert" +) + +func TestGetGocuiStyle(t *testing.T) { + scenarios := []struct { + name string + keys []string + expected gocui.Attribute + }{ + { + name: "named color", + keys: []string{"red"}, + expected: gocui.ColorRed, + }, + { + name: "named color with modifiers", + keys: []string{"red", "bold", "underline"}, + expected: gocui.ColorRed | gocui.AttrBold | gocui.AttrUnderline, + }, + { + name: "strikethrough", + keys: []string{"red", "strikethrough"}, + expected: gocui.ColorRed | gocui.AttrStrikeThrough, + }, + } + + for _, scenario := range scenarios { + t.Run(scenario.name, func(t *testing.T) { + assert.Equal(t, scenario.expected, GetGocuiStyle(scenario.keys)) + }) + } +}