From 7ce427ff47fa613b43b9b5d251fca10768f5da01 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 9 Nov 2016 12:05:45 +0900 Subject: Fix panic when color is disabled and header lines contain ANSI colors Close #732 --- src/result.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/result.go b/src/result.go index c0cf5d61..e2d7c755 100644 --- a/src/result.go +++ b/src/result.go @@ -147,19 +147,21 @@ func (result *Result) colorOffsets(matchOffsets []Offset, theme *tui.ColorTheme, } else { ansi := itemColors[curr-1] fg := ansi.color.fg - if fg == -1 { - if current { - fg = theme.Current - } else { - fg = theme.Fg - } - } bg := ansi.color.bg - if bg == -1 { - if current { - bg = theme.DarkBg - } else { - bg = theme.Bg + if theme != nil { + if fg == -1 { + if current { + fg = theme.Current + } else { + fg = theme.Fg + } + } + if bg == -1 { + if current { + bg = theme.DarkBg + } else { + bg = theme.Bg + } } } colors = append(colors, colorOffset{ -- cgit v1.2.3