summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2016-11-09 12:05:45 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2016-11-09 12:05:45 +0900
commit7ce427ff47fa613b43b9b5d251fca10768f5da01 (patch)
treef33d9e9dbba27d71c53e0d768b0c14ef67b668a6
parenta221c672fbd968ea4cd83557a228065a8fc129f3 (diff)
Fix panic when color is disabled and header lines contain ANSI colors
Close #732
-rw-r--r--src/result.go26
1 files 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{