I think there might be a bug in there. `bytepos_to_local_charpos()` is used in just two places, and then the difference between the two results is used. Both values are off by the same value (filemap.start_pos) so the difference is correct again.

The char-pos calculated by the function can't be global to the whole codemap because it's it does not take into account any filemap before the current one.