chiark / gitweb /
Fix toot length tracking with nontrivial Unicode.
authorSimon Tatham <anakin@pobox.com>
Fri, 12 Jan 2024 12:43:53 +0000 (12:43 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 12 Jan 2024 12:52:04 +0000 (12:52 +0000)
commit2176e02c9036e79cad6c0061e18e603b69762582
tree2f19c3590413961e3eb2aa0618b202018e7e0896
parentb7013418fa93816bcbdb017f62b276ed003cfdbc
Fix toot length tracking with nontrivial Unicode.

Somehow I totally forgot to distinguish chars from bytes in
Composer::make_regions(), _and_ forgot to test it. So I had a crash
this morning when editing a toot containing Unicode put the 500-byte
mark midway through a UTF-8 character.

That's wrong for _two_ reasons - firstly, no endpoint in the regions
array ought to be anywhere other than a character boundary, and
secondly, the 500 _byte_ boundary has nothing to do with the toot
length limit in the first place! The 500 _character_ boundary would
have been more to the point.
src/editor.rs