Conpty cursor mispositioned when using double width lines #19552

Closed
opened 2026-01-31 06:47:02 +00:00 by claunia · 0 comments
Owner

Originally created by @j4james on GitHub (Mar 18, 2023).

Windows Terminal version

1.17.1023

Windows build number

10.0.19044.2364

Other Software

No response

Steps to reproduce

  1. Start a bash shell in Windows Terminal.
  2. Make sure your screen width is an even number of columns.
  3. Execute clear to make sure he screen is cleared.
  4. Execute printf "\e#6\e[999Cv\e#5\n\e#6\e[999C*\e[B^\n"

Expected Behavior

The v and ^ characters should be in the same column, looking something like this:

image

Actual Behavior

The ^ character is one column to the left of v.

image

I'm almost sure this used to work in the past, so I suspect this might be fallout from one of the delayed EOL wrap fixes (possibly PR #14640 or PR #14936).

What's happening is the * is written at the end of a double-width line, so the cursor sets the delayed wrap flag, but doesn't move forward. However, conpty doesn't recognise that state, so it thinks the cursor is one column to the right of where it really is. Then when it needs to move down a row to output the ^, it uses a backspace to adjust the column offset, but that adjustment wasn't needed, so the ^ ends up in the wrong column.

I think the easiest fix for this would be to disable the conpty cursor optimisations whenever we've got double-width lines renditions on the page. That just requires adding the _usingLineRenditions flag to the condition here:

b9248fa903/src/renderer/vt/XtermEngine.cpp (L280-L293)

Originally created by @j4james on GitHub (Mar 18, 2023). ### Windows Terminal version 1.17.1023 ### Windows build number 10.0.19044.2364 ### Other Software _No response_ ### Steps to reproduce 1. Start a bash shell in Windows Terminal. 2. Make sure your screen width is an even number of columns. 3. Execute `clear` to make sure he screen is cleared. 4. Execute `printf "\e#6\e[999Cv\e#5\n\e#6\e[999C*\e[B^\n"` ### Expected Behavior The `v` and `^` characters should be in the same column, looking something like this: ![image](https://user-images.githubusercontent.com/4181424/226129243-d4247605-145b-4dac-9cea-29d3a5047a15.png) ### Actual Behavior The `^` character is one column to the left of `v`. ![image](https://user-images.githubusercontent.com/4181424/226129302-a6e2da28-6412-4d9c-ad4d-b617e328f6f1.png) I'm almost sure this used to work in the past, so I suspect this might be fallout from one of the delayed EOL wrap fixes (possibly PR #14640 or PR #14936). What's happening is the `*` is written at the end of a double-width line, so the cursor sets the delayed wrap flag, but doesn't move forward. However, conpty doesn't recognise that state, so it thinks the cursor is one column to the right of where it really is. Then when it needs to move down a row to output the `^`, it uses a backspace to adjust the column offset, but that adjustment wasn't needed, so the `^` ends up in the wrong column. I think the easiest fix for this would be to disable the conpty cursor optimisations whenever we've got double-width lines renditions on the page. That just requires adding the `_usingLineRenditions` flag to the condition here: https://github.com/microsoft/terminal/blob/b9248fa903eaa8d187c72bf08f8aa17b25f9d6bb/src/renderer/vt/XtermEngine.cpp#L280-L293
claunia added the Help WantedIssue-BugIn-PRArea-VTNeeds-Tag-FixProduct-Conpty labels 2026-01-31 06:47:03 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19552