fix selection bug
TODO: make selection's char index count codepoints, not octets