Fix slice bound error on extremely narrow screen

This commit is contained in:
Junegunn Choi 2020-12-05 21:59:42 +09:00
parent b62a74b315
commit f502725120
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -1116,6 +1116,7 @@ func (t *Terminal) displayWidthWithLimit(runes []rune, prefixWidth int, limit in
}
func (t *Terminal) trimLeft(runes []rune, width int) ([]rune, int32) {
width = util.Max(0, width)
var trimmed int32
// Assume that each rune takes at least one column on screen
if len(runes) > width {