jmacdonald / amp

A complete text editor for your terminal.
https://amp.rs
Other
3.67k stars 105 forks source link

Fix Unicode handling in ensure_trailing_newline #239

Closed oldaccountdeadname closed 2 years ago

oldaccountdeadname commented 2 years ago

If the last line contains some unicode (I ran into this with in particular), adding a trailing newline will fail. This patch just uses line.chars().count() instead of line.len(). This makes the op O(n), but: