Fix a potential crash when there is a line longer than the terminal width (taking two or more lines to display) in the history (using up arrow key) in a ROOT session while the terminal's buffer is full