Skip to content
Myr

Improve rendering time of long lines

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

authored by Junegunn Choi · committed by Junegunn Choi · parent 41e916a · Browse files · 1 file+14 added−5 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+14 added−5 removed

  • other:+14 added−5 removed

1 file+14 added−5 removed

modified:src/terminal.go+14 added-5 removed
654 unmodified lines
655 }656 return runes, trimmed657}658659func overflow(runes []rune, max int) bool {660 l := 0661 for _, r := range runes {662 l += runeWidth(r, l)663 if l > max {664 return true665 }666 }667 return false668}669670func (t *Terminal) printHighlighted(item *Item, bold bool, col1 int, col2 int, current bool) {671 var maxe int672 for _, offset := range item.offsets {673 maxe = util.Max(maxe, int(offset[1]))
4 unmodified lines
678 copy(text, item.text.ToRunes())679 offsets := item.colorOffsets(col2, bold, current)680 maxWidth := t.window.Width - 3681 maxe = util.Constrain(maxe+util.Min(maxWidth/2-2, t.hscrollOff), 0, len(text))671 fullWidth := displayWidth(text)672 if fullWidth > maxWidth {682 if overflow(text, maxWidth) {683 if t.hscroll {684 // Stri..675 matchEndWidth := displayWidth(text[:maxe])676 if matchEndWidth <= maxWidth-2 {685 if !overflow(text[:maxe], maxWidth-2) {686 text, _ = trimRight(text, maxWidth-2)687 text = append(text, []rune("..")...)688 } else {689 // Stri..681 if matchEndWidth < fullWidth-2 {690 if overflow(text[maxe:], 2) {691 text = append(text[:maxe], []rune("..")...)692 }693 // ..ri..694 var diff int32
694 unmodified lines