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

Open
opened 2026-01-31 07:51:49 +00:00 by claunia · 0 comments
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:49 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21679