File tree Expand file tree Collapse file tree 1 file changed +22
-14
lines changed
Expand file tree Collapse file tree 1 file changed +22
-14
lines changed Original file line number Diff line number Diff line change @@ -28,30 +28,38 @@ func logoRenderer() string {
2828 var result strings.Builder
2929 var prev rune
3030
31+ flushResult := func () {
32+ if result .Len () == 0 {
33+ return
34+ }
35+ resultStr := result .String ()
36+ text := strings .ReplaceAll (resultStr , "B" , "@" )
37+ text = strings .ReplaceAll (text , "D" , "@" )
38+ switch resultStr [0 ] {
39+ case 'B' :
40+ output .WriteString (white .Render (text ))
41+ case 'D' :
42+ output .WriteString (blue .Render (text ))
43+ default :
44+ output .WriteString (gray .Render (text ))
45+ }
46+ result .Reset ()
47+ }
48+
3149 for _ , c := range logo {
3250 if c == ' ' {
3351 result .WriteRune (c )
3452 continue
3553 }
3654 if prev != c {
37- if result .Len () > 0 {
38- resultStr := result .String ()
39- text := strings .ReplaceAll (resultStr , "B" , "@" )
40- text = strings .ReplaceAll (text , "D" , "@" )
41- switch resultStr [0 ] {
42- case 'B' :
43- output .WriteString (white .Render (text ))
44- case 'D' :
45- output .WriteString (blue .Render (text ))
46- default :
47- output .WriteString (gray .Render (text ))
48- }
49- result .Reset () // Reset instead of reassigning
50- }
55+ flushResult ()
5156 }
5257 result .WriteRune (c )
5358 prev = c
5459 }
60+
61+ flushResult ()
62+
5563 return output .String ()
5664}
5765
You can’t perform that action at this time.
0 commit comments