Skip to content

readline: fix character width calculation

Fixes width calculation of non-spacing marks, commonly seen in Unicode Normalization Form D. Example: 'a\u0301' ('á'.normalize('NFD')), 'ру́сский язы́к' (Unicode doesn't have many precomposed accented Cyrillic letters).

Outdated information

Not sure where to add tests for this feature though. readline has the following tests:

  • test-readline-csi.js
  • test-readline-emit-keypress-events.js
  • test-readline-interface.js
  • test-readline.js
  • test-readline-keys.js
  • test-readline-reopen.js
  • test-readline-set-raw-mode.js
  • test-readline-undefined-columns.js
  • test-icu-stringwidth.js

None of them seem to fit this bug, which is the glue between getStringWidth and readline, Hence the WIP.


The second commit changes how widths of certain characters are determined:

  • Categorize all nonspacing marks (Mn) and enclosing marks (Me) as 0-width
  • Categorize all spacing marks (Mc) as non-0-width.
  • Do not treat all unassigned code points as 0-width; instead, let ICU select the default for that block.

These decisions are made, partially by following the behavior of GNOME Terminal. Testing on other terminals is of course welcome.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

readline

Merge request reports

Loading