Skip to content

Fix the DECTCEM reset position in the conpty stream#17148

Merged
zadjii-msft merged 1 commit intomicrosoft:mainfrom
j4james:fix-conpty-dectcem
Apr 29, 2024
Merged

Fix the DECTCEM reset position in the conpty stream#17148
zadjii-msft merged 1 commit intomicrosoft:mainfrom
j4james:fix-conpty-dectcem

Conversation

@j4james
Copy link
Collaborator

@j4james j4james commented Apr 27, 2024

Summary of the Pull Request

When the conpty renderer determines that it needs to hide the cursor,
it does so by inserting a DECTCEM reset sequence at the start of the
output buffer, assuming that is the start of the frame. But when the
_noFlushOnEnd flag is set, you can have multiple frames pending in the
buffer, and the DECTCEM sequence will then end up in the wrong place.

This PR fixes the issue by saving the buffer size at the start of the
frame, and using that saved offset as the insert position for the
DECTCEM sequence.

Validation Steps Performed

I have a game that was frequently affected by this issue (the cursor
would be visible when it was meant to be hidden). With this PR applied,
it now works perfectly.

PR Checklist

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-VT Virtual Terminal sequence support Product-Conpty For console issues specifically related to conpty labels Apr 27, 2024
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yea that's an obvious bug for sure

@zadjii-msft zadjii-msft added this pull request to the merge queue Apr 29, 2024
github-merge-queue bot pushed a commit that referenced this pull request Apr 29, 2024
## Summary of the Pull Request

When the conpty renderer determines that it needs to hide the cursor,
it does so by inserting a `DECTCEM` reset sequence at the start of the
output buffer, assuming that is the start of the frame. But when the
`_noFlushOnEnd` flag is set, you can have multiple frames pending in the
buffer, and the `DECTCEM` sequence will then end up in the wrong place.

This PR fixes the issue by saving the buffer size at the start of the
frame, and using that saved offset as the insert position for the
`DECTCEM` sequence.

## Validation Steps Performed

I have a game that was frequently affected by this issue (the cursor
would be visible when it was meant to be hidden). With this PR applied,
it now works perfectly.

## PR Checklist
- [x] Closes #15449
Merged via the queue into microsoft:main with commit ef318a1 Apr 29, 2024
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent catch, thanks!

DHowett pushed a commit that referenced this pull request Apr 30, 2024
## Summary of the Pull Request

When the conpty renderer determines that it needs to hide the cursor,
it does so by inserting a `DECTCEM` reset sequence at the start of the
output buffer, assuming that is the start of the frame. But when the
`_noFlushOnEnd` flag is set, you can have multiple frames pending in the
buffer, and the `DECTCEM` sequence will then end up in the wrong place.

This PR fixes the issue by saving the buffer size at the start of the
frame, and using that saved offset as the insert position for the
`DECTCEM` sequence.

## Validation Steps Performed

I have a game that was frequently affected by this issue (the cursor
would be visible when it was meant to be hidden). With this PR applied,
it now works perfectly.

## PR Checklist
- [x] Closes #15449

(cherry picked from commit ef318a1)
Service-Card-Id: 92457089
Service-Version: 1.19
DHowett pushed a commit that referenced this pull request Apr 30, 2024
## Summary of the Pull Request

When the conpty renderer determines that it needs to hide the cursor,
it does so by inserting a `DECTCEM` reset sequence at the start of the
output buffer, assuming that is the start of the frame. But when the
`_noFlushOnEnd` flag is set, you can have multiple frames pending in the
buffer, and the `DECTCEM` sequence will then end up in the wrong place.

This PR fixes the issue by saving the buffer size at the start of the
frame, and using that saved offset as the insert position for the
`DECTCEM` sequence.

## Validation Steps Performed

I have a game that was frequently affected by this issue (the cursor
would be visible when it was meant to be hidden). With this PR applied,
it now works perfectly.

## PR Checklist
- [x] Closes #15449

(cherry picked from commit ef318a1)
Service-Card-Id: 92457090
Service-Version: 1.20
@j4james j4james deleted the fix-conpty-dectcem branch May 20, 2024 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-VT Virtual Terminal sequence support Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Conpty For console issues specifically related to conpty

Projects

No open projects
Status: Cherry Picked

Development

Successfully merging this pull request may close these issues.

Hidden cursors sometimes reappear unexpectedly

4 participants