From e91e46ac1096a7c0bbdaef67094a6431be9d193b Mon Sep 17 00:00:00 2001 From: stephen cheng Date: Thu, 17 May 2018 17:33:43 +1000 Subject: [PATCH] fix runes index out of range --- util.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util.go b/util.go index 9b6a32d..dc50948 100644 --- a/util.go +++ b/util.go @@ -361,9 +361,13 @@ func printWithStyle(screen tcell.Screen, text string, x, y, maxWidth, align int, width += w start = index } - for runewidth.RuneWidth(runes[start]) == 0 && start < len(runes) { - start++ + + if len(runes) > 0 { + for runewidth.RuneWidth(runes[start]) == 0 && start < len(runes) { + start++ + } } + return printWithStyle(screen, substring(start, len(runes)), x+maxWidth-width, y, width, AlignLeft, style) } else if align == AlignCenter { width := runewidth.StringWidth(strippedText)