File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -532,6 +532,15 @@ export const groupMultiselect = <Options extends Option<Value>[], Value>(
532
532
} ;
533
533
534
534
const strip = ( str : string ) => str . replace ( ansiRegex ( ) , '' ) ;
535
+ const strLength = ( str : string ) => {
536
+ if ( ! str ) return 0 ;
537
+ let len = 0 ;
538
+ const arr = [ ...str ] ;
539
+ for ( const char of arr ) {
540
+ len += char . charCodeAt ( 0 ) > 127 || char . charCodeAt ( 0 ) === 94 ? 2 : 1 ;
541
+ }
542
+ return len ;
543
+ } ;
535
544
export const note = ( message = '' , title = '' ) => {
536
545
const lines = `\n${ message } \n` . split ( '\n' ) ;
537
546
const len =
@@ -540,19 +549,20 @@ export const note = (message = '', title = '') => {
540
549
ln = strip ( ln ) ;
541
550
return ln . length > sum ? ln . length : sum ;
542
551
} , 0 ) ,
543
- strip ( title ) . length
552
+ strLength ( strip ( title ) ) ,
553
+ strLength ( strip ( message ) )
544
554
) + 2 ;
545
555
const msg = lines
546
556
. map (
547
557
( ln ) =>
548
- `${ color . gray ( S_BAR ) } ${ color . dim ( ln ) } ${ ' ' . repeat ( len - strip ( ln ) . length ) } ${ color . gray (
549
- S_BAR
550
- ) } `
558
+ `${ color . gray ( S_BAR ) } ${ color . dim ( ln ) } ${ ' ' . repeat (
559
+ len - strLength ( strip ( ln ) )
560
+ ) } ${ color . gray ( S_BAR ) } `
551
561
)
552
562
. join ( '\n' ) ;
553
563
process . stdout . write (
554
564
`${ color . gray ( S_BAR ) } \n${ color . green ( S_STEP_SUBMIT ) } ${ color . reset ( title ) } ${ color . gray (
555
- S_BAR_H . repeat ( Math . max ( len - title . length - 1 , 1 ) ) + S_CORNER_TOP_RIGHT
565
+ S_BAR_H . repeat ( Math . max ( len - strLength ( title ) - 1 , 1 ) ) + S_CORNER_TOP_RIGHT
556
566
) } \n${ msg } \n${ color . gray ( S_CONNECT_LEFT + S_BAR_H . repeat ( len + 2 ) + S_CORNER_BOTTOM_RIGHT ) } \n`
557
567
) ;
558
568
} ;
You can’t perform that action at this time.
0 commit comments