Fixed bug in cursor position when adding text