Skip to content
Myr

Improve trim function to handle longer strings

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix #2258

authored by Junegunn Choi · committed by Junegunn Choi · parent 7acdaf0 · Browse files · 1 file+6 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−6 removed

  • other:+6 added−6 removed

1 file+6 added−6 removed

modified:src/terminal.go+6 added-6 removed
654 unmodified lines
655656const (657 minWidth = 4658 minHeight = 4659660 maxDisplayWidthCalc = 1024659)660661func calculateSize(base int, size sizeSpec, occupied int, minSize int, pad int) int {662 max := base - occupied
450 unmodified lines
1113 return l1114}11151116func (t *Terminal) trimLeft(runes []rune, width int) ([]rune, int32) {1119 if len(runes) > maxDisplayWidthCalc && len(runes) > width {1120 trimmed := len(runes) - width1121 return runes[trimmed:], int32(trimmed)1117 var trimmed int321118 // Assume that each rune takes at least one column on screen1119 if len(runes) > width {1120 diff := len(runes) - width1121 trimmed = int32(diff)1122 runes = runes[diff:]1123 }11241125 currentWidth := t.displayWidth(runes)1125 var trimmed int3211261127 for currentWidth > width && len(runes) > 0 {1128 runes = runes[1:]1129 trimmed++
1482 unmodified lines