Commit 03efa71
readline: improve getStringWidth()
1. Simplify the getStringWidth function used by Intl builds by removing
dead code (the options were unused) and by refactoring the logic.
2. Improve the getStringWidth unicode handling used by non-Intl builds.
The getStringWidth function returned the wrong width for multiple
inputs. It's now improved by supporting various zero width characters
and more full width characters.
PR-URL: #31112
Reviewed-By: MichaΓ«l Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>1 parent cf28afe commit 03efa71
File tree
3 files changed
+49
-101
lines changed- lib
- internal/readline
- test/parallel
3 files changed
+49
-101
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
| |||
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | | - | |
25 | 22 | | |
26 | 23 | | |
27 | 24 | | |
| |||
41 | 38 | | |
42 | 39 | | |
43 | 40 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
55 | 44 | | |
| 45 | + | |
56 | 46 | | |
57 | 47 | | |
58 | 48 | | |
59 | 49 | | |
60 | | - | |
61 | | - | |
62 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
63 | 53 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 54 | + | |
70 | 55 | | |
71 | 56 | | |
72 | 57 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | 58 | | |
80 | 59 | | |
81 | 60 | | |
82 | 61 | | |
83 | 62 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | 63 | | |
88 | 64 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 65 | + | |
97 | 66 | | |
| 67 | + | |
| 68 | + | |
98 | 69 | | |
99 | 70 | | |
100 | | - | |
| 71 | + | |
101 | 72 | | |
102 | 73 | | |
103 | 74 | | |
| |||
109 | 80 | | |
110 | 81 | | |
111 | 82 | | |
112 | | - | |
113 | | - | |
| 83 | + | |
| 84 | + | |
114 | 85 | | |
115 | | - | |
| 86 | + | |
116 | 87 | | |
117 | 88 | | |
118 | 89 | | |
| |||
139 | 110 | | |
140 | 111 | | |
141 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
142 | 116 | | |
143 | 117 | | |
144 | 118 | | |
145 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
146 | 130 | | |
147 | 131 | | |
148 | 132 | | |
| |||
471 | 455 | | |
472 | 456 | | |
473 | 457 | | |
474 | | - | |
475 | 458 | | |
476 | | - | |
477 | 459 | | |
478 | 460 | | |
479 | 461 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | 56 | | |
58 | | - | |
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
| |||
743 | 741 | | |
744 | 742 | | |
745 | 743 | | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
753 | 747 | | |
754 | 748 | | |
755 | 749 | | |
756 | 750 | | |
757 | | - | |
| 751 | + | |
758 | 752 | | |
759 | 753 | | |
760 | 754 | | |
| |||
781 | 775 | | |
782 | 776 | | |
783 | 777 | | |
784 | | - | |
| 778 | + | |
785 | 779 | | |
786 | 780 | | |
787 | 781 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
716 | 716 | | |
717 | 717 | | |
718 | 718 | | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
| 719 | + | |
724 | 720 | | |
725 | 721 | | |
726 | 722 | | |
| |||
749 | 745 | | |
750 | 746 | | |
751 | 747 | | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
| 748 | + | |
760 | 749 | | |
761 | 750 | | |
762 | 751 | | |
| |||
780 | 769 | | |
781 | 770 | | |
782 | 771 | | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
| 772 | + | |
790 | 773 | | |
791 | 774 | | |
792 | 775 | | |
793 | 776 | | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | | - | |
| 777 | + | |
799 | 778 | | |
800 | 779 | | |
801 | 780 | | |
| |||
957 | 936 | | |
958 | 937 | | |
959 | 938 | | |
960 | | - | |
961 | | - | |
962 | | - | |
963 | | - | |
964 | | - | |
| 939 | + | |
965 | 940 | | |
966 | 941 | | |
967 | 942 | | |
| |||
1144 | 1119 | | |
1145 | 1120 | | |
1146 | 1121 | | |
1147 | | - | |
1148 | | - | |
1149 | | - | |
1150 | | - | |
1151 | | - | |
1152 | 1122 | | |
1153 | | - | |
1154 | | - | |
1155 | | - | |
1156 | | - | |
1157 | | - | |
1158 | | - | |
1159 | | - | |
1160 | | - | |
1161 | | - | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
1162 | 1129 | | |
1163 | 1130 | | |
1164 | 1131 | | |
1165 | 1132 | | |
1166 | 1133 | | |
1167 | 1134 | | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
1168 | 1140 | | |
1169 | 1141 | | |
1170 | 1142 | | |
| |||
0 commit comments