@@ -716,11 +716,7 @@ function isWarned(emitter) {
716716 fi . emit ( 'keypress' , '.' , { name : 'right' } ) ;
717717 cursorPos = rli . getCursorPos ( ) ;
718718 assert . strictEqual ( cursorPos . rows , 0 ) ;
719- if ( common . hasIntl ) {
720- assert . strictEqual ( cursorPos . cols , 2 ) ;
721- } else {
722- assert . strictEqual ( cursorPos . cols , 1 ) ;
723- }
719+ assert . strictEqual ( cursorPos . cols , 2 ) ;
724720
725721 rli . on ( 'line' , common . mustCall ( ( line ) => {
726722 assert . strictEqual ( line , 'π»' ) ;
@@ -749,14 +745,7 @@ function isWarned(emitter) {
749745 fi . emit ( 'data' , 'π' ) ;
750746 cursorPos = rli . getCursorPos ( ) ;
751747 assert . strictEqual ( cursorPos . rows , 0 ) ;
752-
753- if ( common . hasIntl ) {
754- assert . strictEqual ( cursorPos . cols , 2 ) ;
755- } else {
756- assert . strictEqual ( cursorPos . cols , 1 ) ;
757- // Fix cursor position without internationalization
758- fi . emit ( 'keypress' , '.' , { name : 'left' } ) ;
759- }
748+ assert . strictEqual ( cursorPos . cols , 2 ) ;
760749
761750 rli . on ( 'line' , common . mustCall ( ( line ) => {
762751 assert . strictEqual ( line , 'ππ»' ) ;
@@ -780,22 +769,12 @@ function isWarned(emitter) {
780769 fi . emit ( 'keypress' , '.' , { name : 'right' } ) ;
781770 let cursorPos = rli . getCursorPos ( ) ;
782771 assert . strictEqual ( cursorPos . rows , 0 ) ;
783- if ( common . hasIntl ) {
784- assert . strictEqual ( cursorPos . cols , 2 ) ;
785- } else {
786- assert . strictEqual ( cursorPos . cols , 1 ) ;
787- // Fix cursor position without internationalization
788- fi . emit ( 'keypress' , '.' , { name : 'right' } ) ;
789- }
772+ assert . strictEqual ( cursorPos . cols , 2 ) ;
790773
791774 fi . emit ( 'data' , 'π' ) ;
792775 cursorPos = rli . getCursorPos ( ) ;
793776 assert . strictEqual ( cursorPos . rows , 0 ) ;
794- if ( common . hasIntl ) {
795- assert . strictEqual ( cursorPos . cols , 4 ) ;
796- } else {
797- assert . strictEqual ( cursorPos . cols , 2 ) ;
798- }
777+ assert . strictEqual ( cursorPos . cols , 4 ) ;
799778
800779 rli . on ( 'line' , common . mustCall ( ( line ) => {
801780 assert . strictEqual ( line , 'π»π' ) ;
@@ -957,11 +936,7 @@ function isWarned(emitter) {
957936 fi . emit ( 'data' , 'π»' ) ;
958937 let cursorPos = rli . getCursorPos ( ) ;
959938 assert . strictEqual ( cursorPos . rows , 0 ) ;
960- if ( common . hasIntl ) {
961- assert . strictEqual ( cursorPos . cols , 2 ) ;
962- } else {
963- assert . strictEqual ( cursorPos . cols , 1 ) ;
964- }
939+ assert . strictEqual ( cursorPos . cols , 2 ) ;
965940 // Delete left character
966941 fi . emit ( 'keypress' , '.' , { ctrl : true , name : 'h' } ) ;
967942 cursorPos = rli . getCursorPos ( ) ;
@@ -1144,27 +1119,24 @@ function isWarned(emitter) {
11441119 }
11451120 }
11461121
1147- // isFullWidthCodePoint() should return false for non-numeric values
1148- [ true , false , null , undefined , { } , [ ] , 'γ' ] . forEach ( ( v ) => {
1149- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 'γ' ) , false ) ;
1150- } ) ;
1151-
11521122 // Wide characters should be treated as two columns.
1153- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 'a' . charCodeAt ( 0 ) ) ,
1154- false ) ;
1155- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 'γ' . charCodeAt ( 0 ) ) ,
1156- true ) ;
1157- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 'θ°’' . charCodeAt ( 0 ) ) ,
1158- true ) ;
1159- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 'κ³ ' . charCodeAt ( 0 ) ) ,
1160- true ) ;
1161- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 0x1f251 ) , true ) ;
1123+ assert . strictEqual ( internalReadline . getStringWidth ( 'a' ) , 1 ) ;
1124+ assert . strictEqual ( internalReadline . getStringWidth ( 'γ' ) , 2 ) ;
1125+ assert . strictEqual ( internalReadline . getStringWidth ( 'θ°’' ) , 2 ) ;
1126+ assert . strictEqual ( internalReadline . getStringWidth ( 'κ³ ' ) , 2 ) ;
1127+ assert . strictEqual (
1128+ internalReadline . getStringWidth ( String . fromCodePoint ( 0x1f251 ) ) , 2 ) ;
11621129 assert . strictEqual ( internalReadline . getStringWidth ( 'abcde' ) , 5 ) ;
11631130 assert . strictEqual ( internalReadline . getStringWidth ( 'ε€ζ± γ' ) , 6 ) ;
11641131 assert . strictEqual ( internalReadline . getStringWidth ( 'γγΌγ.js' ) , 9 ) ;
11651132 assert . strictEqual ( internalReadline . getStringWidth ( 'δ½ ε₯½' ) , 4 ) ;
11661133 assert . strictEqual ( internalReadline . getStringWidth ( 'μλ
νμΈμ' ) , 10 ) ;
11671134 assert . strictEqual ( internalReadline . getStringWidth ( 'A\ud83c\ude00BC' ) , 5 ) ;
1135+ assert . strictEqual ( internalReadline . getStringWidth ( 'π¨βπ©βπ¦βπ¦' ) , 8 ) ;
1136+ assert . strictEqual ( internalReadline . getStringWidth ( 'ππ·γπ»π' ) , 9 ) ;
1137+ // TODO(BridgeAR): This should have a width of 4.
1138+ assert . strictEqual ( internalReadline . getStringWidth ( 'β¬βͺ' ) , 2 ) ;
1139+ assert . strictEqual ( internalReadline . getStringWidth ( '\u0301\u200D\u200E' ) , 0 ) ;
11681140
11691141 // Check if vt control chars are stripped
11701142 assert . strictEqual (
0 commit comments