onivim / libvim

libvim: The core Vim editing engine as a minimal C library
https://v2.onivim.io
MIT License
691 stars 34 forks source link

fix: UTF-8 input failure for certain characters #217

Closed bryphe closed 4 years ago

bryphe commented 4 years ago

This is the libvim-side fix for https://github.com/onivim/oni2/issues/1720

For a character like , which is a 3-byte UTF-8 character, with bytes (232, 128, 133), it would get expanded by the replace_termcodes call to (232, 128, 254, 88, 133). This is due to special handling around the 128 byte - it gets expanded via K_SPECIAL to its own 3-byte sequences.

This only affected a subset of UTF-8 characters - ones without a 0x80/128 byte would not be impacted by this replacement.

This breaks my assumption that replace_termcodes is safe for arbitrary Unicode values - so I split the vimInput API into two APIs: