commit 6c00c6e

Hubert Hirtz  ·  2020-08-18 10:10:26 +0000 UTC
parent 4f529dd
ui: Fix crash in the word wrapping function
1 files changed,  +1, -1
+1, -1
1@@ -138,7 +138,7 @@ func (l *Line) NewLines(width int) []int {
2 			// Some word occupies the width of the terminal, lets place a
3 			// newline at the PREVIOUS split point (i-2, which is whitespace)
4 			// ONLY if there isn't already one.
5-			if 1 < i && l.newLines[len(l.newLines)-1] != l.splitPoints[i-2].I {
6+			if 1 < i && 0 < len(l.newLines) && l.newLines[len(l.newLines)-1] != l.splitPoints[i-2].I {
7 				l.newLines = append(l.newLines, l.splitPoints[i-2].I)
8 			}
9 			// and also place a newline after the word.