Matteo Berrettini stayed alert after Dominic Thiem’s sliding shot clipped the net and nearly surprised the Italian world number 10.