You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing to a fresh terminal and you resize the terminal to be more narrow than the line with your cursor, truncation will occur instead of reflowing the text and cursor to the next line.
Imagine starting with a 5x5 terminal and writing: "ABCD" . Your cursor is at the last column, denoted by the '@' sign:
Now call .resize(4,5) to resize down a column. We would expect the cursor to wrap down to the next row, but instead it gets squished on top of the letter D:
rows: 5, cols: 4 cursorX: 3, cursorY: 0
+----+
|ABC@| // the 'D' is still in the line buffer, under the '@'
| |
| |
| |
| |
+----+
Call .resize(3,5):
rows: 5, cols: 3 cursorX: 2, cursorY: 0
+---+
|AB@| // The letter 'D' is lost. The cursor is over the 'C'
| |
| |
| |
| |
+---+
Resize back to 5,5 and see what happened:
rows: 5, cols: 5 cursorX: 2, cursorY: 0
+-----+
|AB@ | // the 'C' is still there under the cursor, but the 'D' is lost
| |
| |
| |
| |
+-----+
If we had started with ABCD\r\n instead of ABCD, meaning that the cursor would have started on the second row, then the resizing and line continuations would have reflowed perfectly when we resize the terminal back to original width.
Details
OS version: node 16.20.2 Linux
xterm.js version: xterm-headless 5.3.0
Steps to reproduce
See reproduction JS attached as .txt file
npm i xterm-headless (simpler than using a browser)
node repro.js
optionally toggle the true/false on dump_ascii to make seeing this easier
It's actually the application's job to move the cursor and re-render the lines here. xterm.js does have a reflow feature which reflows wrapped lines, but this explicitly only happens on non-cursor lines.
When writing to a fresh terminal and you resize the terminal to be more narrow than the line with your cursor, truncation will occur instead of reflowing the text and cursor to the next line.
Imagine starting with a 5x5 terminal and writing: "ABCD" . Your cursor is at the last column, denoted by the '@' sign:
Now call .resize(4,5) to resize down a column. We would expect the cursor to wrap down to the next row, but instead it gets squished on top of the letter
D
:Call .resize(3,5):
Resize back to 5,5 and see what happened:
If we had started with
ABCD\r\n
instead ofABCD
, meaning that the cursor would have started on the second row, then the resizing and line continuations would have reflowed perfectly when we resize the terminal back to original width.Details
Steps to reproduce
repro.txt
The text was updated successfully, but these errors were encountered: