Skip to content

Commit 91d0d53

Browse files
BridgeARcodebytere
authored andcommitted
util: support Combining Diacritical Marks for Symbols
This adds support for the "Combining Diacritical Marks for Symbols" unicode group to calculate a zero length width even if Node.js is built without ICU. Signed-off-by: Ruben Bridgewater <[email protected]> PR-URL: #33650 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 4323346 commit 91d0d53

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

lib/internal/util/inspect.js

+2
Original file line numberDiff line numberDiff line change
@@ -2059,6 +2059,8 @@ if (internalBinding('config').hasIntl) {
20592059
(code > 0x7F && code <= 0x9F) || // C1 control codes
20602060
(code >= 0x300 && code <= 0x36F) || // Combining Diacritical Marks
20612061
(code >= 0x200B && code <= 0x200F) || // Modifying Invisible Characters
2062+
// Combining Diacritical Marks for Symbols
2063+
(code >= 0x20D0 && code <= 0x20FF) ||
20622064
(code >= 0xFE00 && code <= 0xFE0F) || // Variation Selectors
20632065
(code >= 0xFE20 && code <= 0xFE2F) || // Combining Half Marks
20642066
(code >= 0xE0100 && code <= 0xE01EF); // Variation Selectors

test/parallel/test-readline-position.js

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Flags: --expose-internals
22
'use strict';
33
const common = require('../common');
4-
const { internalBinding } = require('internal/test/binding');
54
const { PassThrough } = require('stream');
65
const readline = require('readline');
76
const assert = require('assert');
@@ -21,22 +20,14 @@ common.skipIfDumbTerminal();
2120
const tests = [
2221
[1, 'a'],
2322
[2, 'ab'],
24-
[2, '丁']
23+
[2, '丁'],
24+
[0, '\u0301'], // COMBINING ACUTE ACCENT
25+
[1, 'a\u0301'], // á
26+
[0, '\u20DD'], // COMBINING ENCLOSING CIRCLE
27+
[2, 'a\u20DDb'], // a⃝b
28+
[0, '\u200E'], // LEFT-TO-RIGHT MARK
2529
];
2630

27-
// The non-ICU JS implementation of character width calculation is only aware
28-
// of the wide/narrow distinction. Only test these more advanced cases when
29-
// ICU is available.
30-
if (internalBinding('config').hasIntl) {
31-
tests.push(
32-
[0, '\u0301'], // COMBINING ACUTE ACCENT
33-
[1, 'a\u0301'], // á
34-
[0, '\u20DD'], // COMBINING ENCLOSING CIRCLE
35-
[2, 'a\u20DDb'], // a⃝b
36-
[0, '\u200E'] // LEFT-TO-RIGHT MARK
37-
);
38-
}
39-
4031
for (const [cursor, string] of tests) {
4132
rl.write(string);
4233
assert.strictEqual(rl.getCursorPos().cols, cursor);

0 commit comments

Comments
 (0)