Fix cursor positioning issue