Cursor movement is not always detected on double-width lines #21681

Closed
opened 2026-01-31 07:51:54 +00:00 by claunia · 1 comment
Owner

Originally created by @j4james on GitHub (May 9, 2024).

Windows Terminal version

1.21.1272.0

Windows build number

10.0.19045.4291

Other Software

No response

Steps to reproduce

  1. Open a WSL bash shell in Window Terminal
  2. Execute the following statement:
    printf "\e[2 q\e#6\e[11G"; for i in {1..10}; do printf "\e[D"; sleep 1; done
    

Expected Behavior

This starts by setting the cursor style to a steady block so it's easy to see, then positions the cursor in column 11 and moves it left by 1 column every second until it reaches column 1.

Actual Behavior

When it gets to column 3 is pauses for 2 seconds before jumping to column 1. You never see the cursor in column 2.

This is because of the way conpty determines whether the cursor has moved in the InvalidateCursor method here:

49e4eea60f/src/renderer/vt/invalidate.cpp (L78)

The psrRegion is in screen coordinates, while the _lastText position in buffer coordinates. So on a double-width line, when moving from column 3 to column 2, the _lastText column is 3, and the psrRegion->origin is also 3, because buffer column 2 spans screen columns 3 and 4. Thus it seems like no movement has occurred.

This was another bug introduced by PR #17194.

Originally created by @j4james on GitHub (May 9, 2024). ### Windows Terminal version 1.21.1272.0 ### Windows build number 10.0.19045.4291 ### Other Software _No response_ ### Steps to reproduce 1. Open a WSL bash shell in Window Terminal 2. Execute the following statement: ``` printf "\e[2 q\e#6\e[11G"; for i in {1..10}; do printf "\e[D"; sleep 1; done ``` ### Expected Behavior This starts by setting the cursor style to a steady block so it's easy to see, then positions the cursor in column 11 and moves it left by 1 column every second until it reaches column 1. ### Actual Behavior When it gets to column 3 is pauses for 2 seconds before jumping to column 1. You never see the cursor in column 2. This is because of the way conpty determines whether the cursor has moved in the `InvalidateCursor` method here: https://github.com/microsoft/terminal/blob/49e4eea60f737b46b8aeda505f4693df8a9d44a6/src/renderer/vt/invalidate.cpp#L78 The `psrRegion` is in screen coordinates, while the `_lastText` position in buffer coordinates. So on a double-width line, when moving from column 3 to column 2, the `_lastText` column is 3, and the `psrRegion->origin` is also 3, because buffer column 2 spans screen columns 3 and 4. Thus it seems like no movement has occurred. This was another bug introduced by PR #17194.
claunia added the Needs-TriageIssue-Bug labels 2026-01-31 07:51:54 +00:00
Author
Owner

@github-actions[bot] commented on GitHub (May 9, 2024):

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@github-actions[bot] commented on GitHub (May 9, 2024): Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you! ### Open similar issues: - [Conpty cursor mispositioned when using double width lines (#15014)](https://github.com/microsoft/terminal/issues/15014), similarity score: 0.80 ### Closed similar issues: - [Issues with cursor invalidation in GDI (#17150)](https://github.com/microsoft/terminal/issues/17150), similarity score: 0.81 - [Cursor droppings on wide chars in Windows Terminal (#14657)](https://github.com/microsoft/terminal/issues/14657), similarity score: 0.79 - [More cursor droppings (#8213)](https://github.com/microsoft/terminal/issues/8213), similarity score: 0.76 > Note: You can give me feedback by thumbs upping or thumbs downing this comment.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21681