aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-03-21 19:46:27 +0200
committerTulir Asokan <tulir@maunium.net>2018-03-21 19:46:30 +0200
commit0e90972fe8e0e93d67091bab3abdbeb8bdc066e1 (patch)
tree016aea1a46d4983544cc81fa3c4e8920ff6dc01d /ui
parent35b6c7bd276d2a6c7f09163d757a1c3cb885da79 (diff)
Handle some corner cases in MessageView
Diffstat (limited to 'ui')
-rw-r--r--ui/widget/message-view.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/ui/widget/message-view.go b/ui/widget/message-view.go
index 78d37c1..941b987 100644
--- a/ui/widget/message-view.go
+++ b/ui/widget/message-view.go
@@ -22,6 +22,7 @@ import (
"github.com/gdamore/tcell"
"github.com/mattn/go-runewidth"
+ "maunium.net/go/gomuks/ui/debug"
"maunium.net/go/gomuks/ui/types"
"maunium.net/go/tview"
)
@@ -276,11 +277,15 @@ func (view *MessageView) Draw(screen tcell.Screen) {
}
view.writeLine(screen, message, x+messageOffsetX, y, tcell.ColorGreen)
}
+ if len(view.textBuffer) != len(view.metaBuffer) {
+ debug.ExtPrintf("Unexpected text/meta buffer length mismatch: %d != %d.", len(view.textBuffer), len(view.metaBuffer))
+ return
+ }
for line := 0; line < height; line++ {
index := indexOffset + line
if index < 0 {
continue
- } else if index > len(view.textBuffer) {
+ } else if index >= len(view.textBuffer) {
break
}
text, meta := view.textBuffer[index], view.metaBuffer[index]