Fix cursor position bug