@@ -716,11 +716,7 @@ function isWarned(emitter) {
716
716
fi . emit ( 'keypress' , '.' , { name : 'right' } ) ;
717
717
cursorPos = rli . getCursorPos ( ) ;
718
718
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 ) ;
724
720
725
721
rli . on ( 'line' , common . mustCall ( ( line ) => {
726
722
assert . strictEqual ( line , 'π»' ) ;
@@ -749,14 +745,7 @@ function isWarned(emitter) {
749
745
fi . emit ( 'data' , 'π' ) ;
750
746
cursorPos = rli . getCursorPos ( ) ;
751
747
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 ) ;
760
749
761
750
rli . on ( 'line' , common . mustCall ( ( line ) => {
762
751
assert . strictEqual ( line , 'ππ»' ) ;
@@ -780,22 +769,12 @@ function isWarned(emitter) {
780
769
fi . emit ( 'keypress' , '.' , { name : 'right' } ) ;
781
770
let cursorPos = rli . getCursorPos ( ) ;
782
771
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 ) ;
790
773
791
774
fi . emit ( 'data' , 'π' ) ;
792
775
cursorPos = rli . getCursorPos ( ) ;
793
776
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 ) ;
799
778
800
779
rli . on ( 'line' , common . mustCall ( ( line ) => {
801
780
assert . strictEqual ( line , 'π»π' ) ;
@@ -957,11 +936,7 @@ function isWarned(emitter) {
957
936
fi . emit ( 'data' , 'π»' ) ;
958
937
let cursorPos = rli . getCursorPos ( ) ;
959
938
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 ) ;
965
940
// Delete left character
966
941
fi . emit ( 'keypress' , '.' , { ctrl : true , name : 'h' } ) ;
967
942
cursorPos = rli . getCursorPos ( ) ;
@@ -1144,27 +1119,24 @@ function isWarned(emitter) {
1144
1119
}
1145
1120
}
1146
1121
1147
- // isFullWidthCodePoint() should return false for non-numeric values
1148
- [ true , false , null , undefined , { } , [ ] , 'γ' ] . forEach ( ( v ) => {
1149
- assert . strictEqual ( internalReadline . isFullWidthCodePoint ( 'γ' ) , false ) ;
1150
- } ) ;
1151
-
1152
1122
// 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 ) ;
1162
1129
assert . strictEqual ( internalReadline . getStringWidth ( 'abcde' ) , 5 ) ;
1163
1130
assert . strictEqual ( internalReadline . getStringWidth ( 'ε€ζ± γ' ) , 6 ) ;
1164
1131
assert . strictEqual ( internalReadline . getStringWidth ( 'γγΌγ.js' ) , 9 ) ;
1165
1132
assert . strictEqual ( internalReadline . getStringWidth ( 'δ½ ε₯½' ) , 4 ) ;
1166
1133
assert . strictEqual ( internalReadline . getStringWidth ( 'μλ
νμΈμ' ) , 10 ) ;
1167
1134
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 ) ;
1168
1140
1169
1141
// Check if vt control chars are stripped
1170
1142
assert . strictEqual (
0 commit comments