Skip to content
Myr

Truncate wrap signs in extremely narrow preview window

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 282884a · Browse files · 2 files+18 added−3 removed
This commit

State

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

Diff stats

2 files+18 added−3 removed

  • other:+18 added−3 removed

2 files+18 added−3 removed

modified:src/tui/light.go+9 added-2 removed
1157 unmodified lines
1158 w.MoveAndClear(w.posy, w.posx)1159 w.Move(w.posy+1, 0)1160 w.renderer.stderr(resetCode)1161 if len(lines) > 1 {1162 sign := w.wrapSign1163 width := w.wrapSignWidth1164 if width > w.width-w.posx {1165 runes, truncatedWidth := util.Truncate(w.wrapSign, w.width-w.posx)1166 sign = string(runes)1167 width = truncatedWidth1168 }1162 w.stderrInternal(DIM+w.wrapSign, false, resetCode)1169 w.stderrInternal(DIM+sign, false, resetCode)1170 w.renderer.stderr(resetCode)1164 w.Move(w.posy, w.wrapSignWidth)1171 w.Move(w.posy, width)1172 }1173 }1174 }1175 }
84 unmodified lines
modified:src/tui/tcell.go+9 added-1 removed
764 unmodified lines
765 // word wrap:766 xPos := w.left + w.lastX + lx767 if xPos >= w.left+w.width {768 w.lastY++769 if w.lastY >= w.height {770 return FillSuspend771 }772 w.lastX = 0773 lx = 0774 xPos = w.left775 sign := w.wrapSign776 if w.wrapSignWidth > w.width {777 runes, _ := util.Truncate(sign, w.width)778 sign = string(runes)779 }772 wgr := uniseg.NewGraphemes(w.wrapSign)780 wgr := uniseg.NewGraphemes(sign)781 for wgr.Next() {782 rs := wgr.Runes()783 _screen.SetContent(w.left+lx, w.top+w.lastY, rs[0], rs[1:], style.Dim(true))784 lx += uniseg.StringWidth(string(rs))
135 unmodified lines