From d6ddc94f3b3fa8a2926e9af59dcf65900802126b Mon Sep 17 00:00:00 2001 From: ZadenRB Date: Sun, 29 Jul 2018 23:29:26 -0600 Subject: [PATCH] Adds nil check to opSearch source in ExitSearchMode to prevent panic when exiting search mode with no history --- search.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/search.go b/search.go index 52e8ff0..2513758 100644 --- a/search.go +++ b/search.go @@ -114,8 +114,12 @@ func (o *opSearch) SearchMode(dir int) bool { func (o *opSearch) ExitSearchMode(revert bool) { if revert { - o.history.current = o.source - o.buf.Set(o.history.showItem(o.history.current.Value)) + if o.source != nil { + o.history.current = o.source + o.buf.Set(o.history.showItem(o.history.current.Value)) + } else { + o.buf.Set(make([]rune, 0)) + } } o.markStart, o.markEnd = 0, 0 o.state = S_STATE_FOUND