@@ -731,11 +731,7 @@ function isWarned(emitter) {
731
731
fi . emit ( 'keypress' , '.' , { name : 'right' } ) ;
732
732
cursorPos = rli . getCursorPos ( ) ;
733
733
assert . strictEqual ( cursorPos . rows , 0 ) ;
734
- if ( common . hasIntl ) {
735
- assert . strictEqual ( cursorPos . cols , 2 ) ;
736
- } else {
737
- assert . strictEqual ( cursorPos . cols , 1 ) ;
738
- }
734
+ assert . strictEqual ( cursorPos . cols , 2 ) ;
739
735
740
736
rli . on ( 'line' , common . mustCall ( ( line ) => {
741
737
assert . strictEqual ( line , 'π»' ) ;
@@ -764,14 +760,7 @@ function isWarned(emitter) {
764
760
fi . emit ( 'data' , 'π' ) ;
765
761
cursorPos = rli . getCursorPos ( ) ;
766
762
assert . strictEqual ( cursorPos . rows , 0 ) ;
767
-
768
- if ( common . hasIntl ) {
769
- assert . strictEqual ( cursorPos . cols , 2 ) ;
770
- } else {
771
- assert . strictEqual ( cursorPos . cols , 1 ) ;
772
- // Fix cursor position without internationalization
773
- fi . emit ( 'keypress' , '.' , { name : 'left' } ) ;
774
- }
763
+ assert . strictEqual ( cursorPos . cols , 2 ) ;
775
764
776
765
rli . on ( 'line' , common . mustCall ( ( line ) => {
777
766
assert . strictEqual ( line , 'ππ»' ) ;
@@ -795,22 +784,12 @@ function isWarned(emitter) {
795
784
fi . emit ( 'keypress' , '.' , { name : 'right' } ) ;
796
785
let cursorPos = rli . getCursorPos ( ) ;
797
786
assert . strictEqual ( cursorPos . rows , 0 ) ;
798
- if ( common . hasIntl ) {
799
- assert . strictEqual ( cursorPos . cols , 2 ) ;
800
- } else {
801
- assert . strictEqual ( cursorPos . cols , 1 ) ;
802
- // Fix cursor position without internationalization
803
- fi . emit ( 'keypress' , '.' , { name : 'right' } ) ;
804
- }
787
+ assert . strictEqual ( cursorPos . cols , 2 ) ;
805
788
806
789
fi . emit ( 'data' , 'π' ) ;
807
790
cursorPos = rli . getCursorPos ( ) ;
808
791
assert . strictEqual ( cursorPos . rows , 0 ) ;
809
- if ( common . hasIntl ) {
810
- assert . strictEqual ( cursorPos . cols , 4 ) ;
811
- } else {
812
- assert . strictEqual ( cursorPos . cols , 2 ) ;
813
- }
792
+ assert . strictEqual ( cursorPos . cols , 4 ) ;
814
793
815
794
rli . on ( 'line' , common . mustCall ( ( line ) => {
816
795
assert . strictEqual ( line , 'π»π' ) ;
@@ -972,11 +951,7 @@ function isWarned(emitter) {
972
951
fi . emit ( 'data' , 'π»' ) ;
973
952
let cursorPos = rli . getCursorPos ( ) ;
974
953
assert . strictEqual ( cursorPos . rows , 0 ) ;
975
- if ( common . hasIntl ) {
976
- assert . strictEqual ( cursorPos . cols , 2 ) ;
977
- } else {
978
- assert . strictEqual ( cursorPos . cols , 1 ) ;
979
- }
954
+ assert . strictEqual ( cursorPos . cols , 2 ) ;
980
955
// Delete left character
981
956
fi . emit ( 'keypress' , '.' , { ctrl : true , name : 'h' } ) ;
982
957
cursorPos = rli . getCursorPos ( ) ;
@@ -1159,27 +1134,24 @@ function isWarned(emitter) {
1159
1134
}
1160
1135
}
1161
1136
1162
- // isFullWidthCodePoint() should return false for non-numeric values
1163
- [ true , false , null , undefined , { } , [ ] , 'γ' ] . forEach ( ( v ) => {
1164
- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 'γ' ) , false ) ;
1165
- } ) ;
1166
-
1167
1137
// Wide characters should be treated as two columns.
1168
- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 'a' . charCodeAt ( 0 ) ) ,
1169
- false ) ;
1170
- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 'γ' . charCodeAt ( 0 ) ) ,
1171
- true ) ;
1172
- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 'θ°’' . charCodeAt ( 0 ) ) ,
1173
- true ) ;
1174
- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 'κ³ ' . charCodeAt ( 0 ) ) ,
1175
- true ) ;
1176
- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 0x1f251 ) , true ) ;
1138
+ assert . strictEqual ( internalReadline . getStringWidth ( 'a' ) , 1 ) ;
1139
+ assert . strictEqual ( internalReadline . getStringWidth ( 'γ' ) , 2 ) ;
1140
+ assert . strictEqual ( internalReadline . getStringWidth ( 'θ°’' ) , 2 ) ;
1141
+ assert . strictEqual ( internalReadline . getStringWidth ( 'κ³ ' ) , 2 ) ;
1142
+ assert . strictEqual (
1143
+ internalReadline . getStringWidth ( String . fromCodePoint ( 0x1f251 ) ) , 2 ) ;
1177
1144
assert . strictEqual ( internalReadline . getStringWidth ( 'abcde' ) , 5 ) ;
1178
1145
assert . strictEqual ( internalReadline . getStringWidth ( 'ε€ζ± γ' ) , 6 ) ;
1179
1146
assert . strictEqual ( internalReadline . getStringWidth ( 'γγΌγ.js' ) , 9 ) ;
1180
1147
assert . strictEqual ( internalReadline . getStringWidth ( 'δ½ ε₯½' ) , 4 ) ;
1181
1148
assert . strictEqual ( internalReadline . getStringWidth ( 'μλ
νμΈμ' ) , 10 ) ;
1182
1149
assert . strictEqual ( internalReadline . getStringWidth ( 'A\ud83c\ude00BC' ) , 5 ) ;
1150
+ assert . strictEqual ( internalReadline . getStringWidth ( 'π¨βπ©βπ¦βπ¦' ) , 8 ) ;
1151
+ assert . strictEqual ( internalReadline . getStringWidth ( 'ππ·γπ»π' ) , 9 ) ;
1152
+ // TODO(BridgeAR): This should have a width of 4.
1153
+ assert . strictEqual ( internalReadline . getStringWidth ( 'β¬βͺ' ) , 2 ) ;
1154
+ assert . strictEqual ( internalReadline . getStringWidth ( '\u0301\u200D\u200E' ) , 0 ) ;
1183
1155
1184
1156
// Check if vt control chars are stripped
1185
1157
assert . strictEqual (
0 commit comments