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:
It's O(n) only with respect to the length of a line.
If the last line contains some unicode (I ran into this with
∴
in particular), adding a trailing newline will fail. This patch just usesline.chars().count()
instead ofline.len()
. This makes the op O(n), but: