fixed measuring of empty span
fixed calculation of cursorIndex