Codebase list golang-github-vbauerster-mpb / 3cc9b32
limit gr.Next iteration by len of BarDefaultStyle Vladimir Bauer 5 years ago
1 changed file(s) with 8 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
9393 if !utf8.ValidString(style) {
9494 panic("invalid bar style")
9595 }
96 srcFormat := make([][]byte, 0, len(BarDefaultStyle))
97 srcRwidth := make([]int, 0, len(BarDefaultStyle))
98 gr := uniseg.NewGraphemes(style)
99 for gr.Next() {
100 srcFormat = append(srcFormat, gr.Bytes())
101 srcRwidth = append(srcRwidth, runewidth.StringWidth(gr.Str()))
96 srcFormat := make([][]byte, len(BarDefaultStyle))
97 srcRwidth := make([]int, len(BarDefaultStyle))
98 i := 0
99 for gr := uniseg.NewGraphemes(style); i < len(BarDefaultStyle) && gr.Next(); i++ {
100 srcFormat[i] = gr.Bytes()
101 srcRwidth[i] = runewidth.StringWidth(gr.Str())
102102 }
103 copy(s.format, srcFormat)
104 copy(s.rwidth, srcRwidth)
103 copy(s.format, srcFormat[:i])
104 copy(s.rwidth, srcRwidth[:i])
105105 if s.reverse {
106106 s.tip = s.format[rRevTip]
107107 s.flush = reverseFlush