Skip to content

Commit 10a3ce9

Browse files
committed
add spaces == width+chWidth-w
1 parent 6dff02e commit 10a3ce9

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Diff for: runewidth.go

+9-11
Original file line numberDiff line numberDiff line change
@@ -234,20 +234,18 @@ func (c *Condition) TruncateLeft(s string, w int, prefix string) string {
234234
}
235235
}
236236

237-
if width+chWidth <= w {
238-
width += chWidth
239-
240-
continue
241-
}
237+
if width+chWidth > w {
238+
if width < w {
239+
_, pos = g.Positions()
240+
prefix += strings.Repeat(" ", width+chWidth-w)
241+
} else {
242+
pos, _ = g.Positions()
243+
}
242244

243-
if width < w {
244-
_, pos = g.Positions()
245-
prefix += strings.Repeat(" ", w-width)
246-
} else {
247-
pos, _ = g.Positions()
245+
break
248246
}
249247

250-
break
248+
width += chWidth
251249
}
252250

253251
return prefix + s[pos:]

0 commit comments

Comments
 (0)