Fixed scrolling issue in terminal (IDEA-125223).

(cherry picked from commit 70e83b9b93cd4712c500758ab251c680b08fce72)