Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing truncates text on line with the cursor #4824

Closed
davidfiala opened this issue Sep 25, 2023 · 1 comment
Closed

Resizing truncates text on line with the cursor #4824

davidfiala opened this issue Sep 25, 2023 · 1 comment

Comments

@davidfiala
Copy link
Contributor

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:

rows: 5, cols: 5 cursorX: 4, cursorY: 0
+-----+
|ABCD@|
|     |
|     |
|     |
|     |
+-----+

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

  1. See reproduction JS attached as .txt file
  2. npm i xterm-headless (simpler than using a browser)
  3. node repro.js
  4. optionally toggle the true/false on dump_ascii to make seeing this easier

repro.txt

@Tyriar
Copy link
Member

Tyriar commented Oct 2, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants