Backspace in wrapped cooked read erases char on line above #21963

Closed
opened 2026-01-31 07:59:29 +00:00 by claunia · 2 comments
Owner

Originally created by @j4james on GitHub (Jul 12, 2024).

Originally assigned to: @lhecker on GitHub.

Windows Terminal version

Commit ac5b4f5831

Windows build number

10.0.19045.4529

Other Software

No response

Steps to reproduce

  1. Checkout the latest code from main (ac5b4f5831 or later).
  2. Start a cmd shell in OpenConsole.
  3. Type some content at the prompt until it wraps onto the second line.
  4. Backspace until the cursor is at the start of that second line.

Expected Behavior

Backspaces on the second line should have no effect on the characters in the first line.

Actual Behavior

The last character on the first line gets erased when backspacing over the first character in the second line.

This is what it looks like after wrapping.
image

And this is what it looks like after two backspaces. Notice the r erased from the first line.
image

The same thing occurs in both OpenConsole and Windows Terminal. I think this was introduced by the new VT cooked read implementation (PR #17445).

Originally created by @j4james on GitHub (Jul 12, 2024). Originally assigned to: @lhecker on GitHub. ### Windows Terminal version Commit ac5b4f5831c125e7defe65eab93d3928b282559f ### Windows build number 10.0.19045.4529 ### Other Software _No response_ ### Steps to reproduce 1. Checkout the latest code from main (ac5b4f5831c125e7defe65eab93d3928b282559f or later). 2. Start a cmd shell in OpenConsole. 3. Type some content at the prompt until it wraps onto the second line. 4. Backspace until the cursor is at the start of that second line. ### Expected Behavior Backspaces on the second line should have no effect on the characters in the first line. ### Actual Behavior The last character on the first line gets erased when backspacing over the first character in the second line. This is what it looks like after wrapping. ![image](https://github.com/user-attachments/assets/c31b06fa-52c1-4a74-b4ab-7eda11111eae) And this is what it looks like after two backspaces. Notice the `r` erased from the first line. ![image](https://github.com/user-attachments/assets/e6e440b0-0460-452e-92f0-cc14cadce133) The same thing occurs in both OpenConsole and Windows Terminal. I think this was introduced by the new VT cooked read implementation (PR #17445).
claunia added the Product-ConhostNeeds-TriageIssue-BugIn-PRArea-CookedRead labels 2026-01-31 07:59:29 +00:00
Author
Owner

@j4james commented on GitHub (Jul 12, 2024):

I should note that this is just a visual glitch. The actual prompt content is correct. It just looks like a character is missing.

@j4james commented on GitHub (Jul 12, 2024): I should note that this is just a visual glitch. The actual prompt content is correct. It just looks like a character is missing.
Author
Owner

@lhecker commented on GitHub (Jul 12, 2024):

Your issue occurs because if (pagerPromptEnd.x >= size.width) must be after if (pagerPromptEnd.y <= _pagerPromptEnd.y) and not before it (I think).

I found two more bugs:

  • Writing a wide glyph into the last column breaks the cursor position.
    Fixed by moving dist += state.len; in TextBuffer::FitTextIntoColumns to the end of the loop.
  • Having a fairly full prompt (e.g. 80% of the viewport height) and pressing F7 with a rather full history will move the prompt contents upwards. But when dismissing F7 via ESC it'll not restore the prompt to its previous state.
@lhecker commented on GitHub (Jul 12, 2024): Your issue occurs because `if (pagerPromptEnd.x >= size.width)` must be after `if (pagerPromptEnd.y <= _pagerPromptEnd.y)` and not before it (I think). I found two more bugs: * Writing a wide glyph into the last column breaks the cursor position. Fixed by moving `dist += state.len;` in `TextBuffer::FitTextIntoColumns` to the end of the loop. * Having a fairly full prompt (e.g. 80% of the viewport height) and pressing F7 with a rather full history will move the prompt contents upwards. But when dismissing F7 via ESC it'll not restore the prompt to its previous state.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21963