From d82ea2279d1341b38dca21f3a97716c06ed5ddd8 Mon Sep 17 00:00:00 2001 From: Ted Singer Date: Sat, 21 Oct 2017 18:59:11 -0400 Subject: [PATCH] If the history file is unreadable or unparseable, Messenger.history remained nil, causing a panic on read. Now in that case, we temporarily disable saving history and initialize history to empty, instead of nil --- cmd/micro/messenger.go | 2 ++ cmd/micro/settings.go | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/micro/messenger.go b/cmd/micro/messenger.go index 1212725b..bc71b644 100644 --- a/cmd/micro/messenger.go +++ b/cmd/micro/messenger.go @@ -501,6 +501,8 @@ func (m *Messenger) LoadHistory() { if err != nil { m.Error("Error loading history:", err) + SetOption("savehistory", "false") + m.history = make(map[string][]string) return } diff --git a/cmd/micro/settings.go b/cmd/micro/settings.go index 02f61313..f35a3beb 100644 --- a/cmd/micro/settings.go +++ b/cmd/micro/settings.go @@ -326,10 +326,12 @@ func SetOption(option, value string) error { } } - if _, ok := CurView().Buf.Settings[option]; ok { - for _, tab := range tabs { - for _, view := range tab.views { - SetLocalOption(option, value, view) + if len(tabs) != 0 { + if _, ok := CurView().Buf.Settings[option]; ok { + for _, tab := range tabs { + for _, view := range tab.views { + SetLocalOption(option, value, view) + } } } }