From 16406d6c91acf322463b64d03a49af6aebc02834 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 23 Apr 2018 20:13:42 +0300 Subject: [PATCH] Fix panic if replaceBuffer() is called with message not in buffer. Fixes #32 --- ui/message-view.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/message-view.go b/ui/message-view.go index 71d1cba..ca03e73 100644 --- a/ui/message-view.go +++ b/ui/message-view.go @@ -231,6 +231,12 @@ func (view *MessageView) replaceBuffer(original messages.UIMessage, new messages } } + if start == -1 { + debug.Print("Called replaceBuffer() with message that was not in the buffer:", original) + view.appendBuffer(new) + return + } + if len(view.textBuffer) > end { end++ }