Skip to content
Myr

Fix ANSI color offsets when --keep-right is used

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 c39113e · Browse files · 1 file+14 added−10 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−10 removed

  • other:+14 added−10 removed

1 file+14 added−10 removed

modified:src/terminal.go+14 added-10 removed
1001 unmodified lines
1002 maxWidth := t.window.Width() - 31003 maxe = util.Constrain(maxe+util.Min(maxWidth/2-2, t.hscrollOff), 0, len(text))1004 displayWidth := t.displayWidthWithLimit(text, 0, maxWidth)1005 if displayWidth > maxWidth {1006 transformOffsets := func(diff int32) {1007 for idx, offset := range offsets {1008 b, e := offset.offset[0], offset.offset[1]1009 b += 2 - diff1010 e += 2 - diff1011 b = util.Max32(b, 2)1012 offsets[idx].offset[0] = b1013 offsets[idx].offset[1] = util.Max32(b, e)1014 }1015 }1016 if t.hscroll {1017 if t.keepRight && pos == nil {1008 text, _ = t.trimLeft(text, maxWidth-2)1009 text = append([]rune(ellipsis), text...)1018 trimmed, diff := t.trimLeft(text, maxWidth-2)1019 transformOffsets(diff)1020 text = append([]rune(ellipsis), trimmed...)1021 } else if !t.overflow(text[:maxe], maxWidth-2) {1022 // Stri..1023 text, _ = t.trimRight(text, maxWidth-2)1024 text = append(text, []rune(ellipsis)...)
6 unmodified lines
1031 var diff int321032 text, diff = t.trimLeft(text, maxWidth-2)10331034 // Transform offsets1024 for idx, offset := range offsets {1025 b, e := offset.offset[0], offset.offset[1]1026 b += 2 - diff1027 e += 2 - diff1028 b = util.Max32(b, 2)1029 offsets[idx].offset[0] = b1030 offsets[idx].offset[1] = util.Max32(b, e)1031 }1035 transformOffsets(diff)1036 text = append([]rune(ellipsis), text...)1037 }1038 } else {1039 text, _ = t.trimRight(text, maxWidth-2)
1192 unmodified lines