@@ -188,8 +188,8 @@ suite("hatStats", () => {
188188 const lineTokens = allTokens . filter (
189189 ( token ) => token . token . range . end . line === lineno ,
190190 ) ;
191- let shapeLine = "" ;
192- let colorLine = "" ;
191+ let line1 = "" ;
192+ let line2 = "" ;
193193 let rangeLine = "" ;
194194 lineTokens . forEach ( ( token ) => {
195195 const tokenRange = token . token . range ;
@@ -209,15 +209,24 @@ suite("hatStats", () => {
209209 }
210210 const hatRange = hat . hatRange ;
211211 const [ color , shape ] = colorShapeForHatStyle ( hat . hatStyle ) ;
212- shapeLine += " " . repeat (
213- hatRange . start . character - shapeLine . length ,
214- ) ;
215- shapeLine += charForShape . get ( shape ) ;
216- if ( color !== "default" ) {
217- colorLine += " " . repeat (
218- hatRange . start . character - colorLine . length ,
219- ) ;
220- colorLine += charForColor . get ( color ) ;
212+ const penalty = penaltyForHatStyle ( hat . hatStyle ) ;
213+ if ( penalty == 0 ) {
214+ line1 += " " . repeat ( hatRange . start . character - line1 . length ) ;
215+ line1 += "_" ;
216+ } else if ( penalty == 1 ) {
217+ const char =
218+ color == "default"
219+ ? charForShape . get ( shape )
220+ : charForColor . get ( color ) ;
221+ line1 += " " . repeat ( hatRange . start . character - line1 . length ) ;
222+ line1 += char ;
223+ } else if ( penalty == 2 ) {
224+ line1 += " " . repeat ( hatRange . start . character - line1 . length ) ;
225+ line1 += charForShape . get ( shape ) ;
226+ line2 += " " . repeat ( hatRange . start . character - line2 . length ) ;
227+ line2 += charForColor . get ( color ) ;
228+ } else {
229+ throw new Error ( `unexpected penalty: ${ penalty } ` ) ;
221230 }
222231 const width =
223232 tokenRange . end . character - tokenRange . start . character ;
@@ -236,11 +245,11 @@ suite("hatStats", () => {
236245 ) ;
237246 rangeLine += rangeStr ;
238247 } ) ;
239- if ( colorLine . length !== 0 ) {
240- w . write ( colorLine + "\n" ) ;
248+ if ( line2 . length !== 0 ) {
249+ w . write ( line2 + "\n" ) ;
241250 }
242- if ( colorLine . length !== 0 || shapeLine . length !== 0 ) {
243- w . write ( shapeLine + "\n" ) ;
251+ if ( line1 . length !== 0 ) {
252+ w . write ( line1 + "\n" ) ;
244253 }
245254 if ( line . length !== 0 ) {
246255 // TODO: tabs, emoji, sigh
0 commit comments