term.js
term.js copied to clipboard
Saved cursor should stay on screen.
Term.js will crash by writing past this.lines if you save cursor position with a bigger terminal, then resize it to a smaller one, then try to restore the cursor position. To reproduce the problem:
- assume the initial window size is 20
- move cursor to the last row (y = 20)
- enter into vim (savedY = 20)
- resize terminal to 15 (rows = 15)
- exit vim, which triggers cursor restore. this.y = this.savedY (y = 20, rows = 15)
- terminal crashes when receiving new data
This patch makes sure that saved cursor position will stay on screen (as normal cursors do).