fix some bug of moving cursor