Avoid rendering delay when displaying extremely long lines

Related #666
This commit is contained in:
Junegunn Choi 2016-09-21 01:23:41 +09:00
parent a749e6bd16
commit 00f96aae76
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -401,6 +401,8 @@ func displayWidth(runes []rune) int {
const (
minWidth = 16
minHeight = 4
maxDisplayWidthCalc = 1024
)
func calculateSize(base int, size sizeSpec, margin int, minSize int) int {
@ -651,6 +653,11 @@ func displayWidthWithLimit(runes []rune, prefixWidth int, limit int) int {
}
func trimLeft(runes []rune, width int) ([]rune, int32) {
if len(runes) > maxDisplayWidthCalc && len(runes) > width {
trimmed := len(runes) - width
return runes[trimmed:], int32(trimmed)
}
currentWidth := displayWidth(runes)
var trimmed int32