Receiving new messages won't change the selection anymore
@@ -195,8 +195,10 @@ func intToString(value int) string {
func (chatView *ChatView) updateHighlights() {
chatView.internalTextView.Highlight(intToString(chatView.selection))
+ if chatView.selection != -1 {
chatView.internalTextView.ScrollToHighlight()
}
+}
// GetPrimitive returns the component that can be added to a layout, since
// the ChatView itself is not a component.
@@ -280,6 +282,10 @@ func (chatView *ChatView) addMessageInternal(message *discordgo.Message) {
delete(chatView.formattedMessages, idToDrop)
chatView.data = append(chatView.data[1:], message)
rerender = true
+ if chatView.selection > -1 {
+ chatView.selection--
+ }
+ chatView.updateHighlights()
} else {
chatView.data = append(chatView.data, message)
}
