revery-ui / revery

:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
https://www.outrunlabs.com/revery/
MIT License
8.06k stars 196 forks source link

fix(font): Fix hang in font-fallback code #970

Closed bryphe closed 4 years ago

bryphe commented 4 years ago

Issue: Certain unicode constructions could cause the font-fallback algorithm to hang, as described in https://github.com/onivim/oni2/issues/2178

Defect: We'd run into an infinite loop in the fallbackFor code, because we were assuming a character index when we actually needed a byte offset. This is another case where it'd be great to have the type system help us differentiate between these!

Fix: The value passed into fallbackFor is a byte index, not a character index - so use Zed_utf8.extract, which operates on byte offsets, instead of get, which operates on character indices. Add several test cases.

bryphe commented 4 years ago

Looks like this fixes the issue with the test file that was hanging, previously:

image