Skip to content

Fix DECSTR cursor restore in alt screen buffer (#19918)#20032

Open
aarushisingh04 wants to merge 1 commit intomicrosoft:mainfrom
aarushisingh04:fix/19918-decstr-alt-screen-buffer-main
Open

Fix DECSTR cursor restore in alt screen buffer (#19918)#20032
aarushisingh04 wants to merge 1 commit intomicrosoft:mainfrom
aarushisingh04:fix/19918-decstr-alt-screen-buffer-main

Conversation

@aarushisingh04
Copy link
Copy Markdown

summary of the pull request

fixes decstr behavior so a soft reset in the alt screen buffer does not clear the saved cursor state for the main screen buffer.

references and relevant issues

detailed description of the pull request / additional comments

the prior implementation of AdaptDispatch::SoftReset() reset both saved cursor states unconditionally:

  • main buffer saved cursor state
  • alt buffer saved cursor state

this caused a regression where sending decstr (esc[!p) while in the alt buffer could clear the main buffer cursor restore point, so returning from alt buffer no longer restored the expected cursor position.

this change updates soft reset behavior to clear only the saved cursor state for the currently active buffer, matching expected xterm-compatible behavior and preserving main buffer cursor restore data when resetting in alt mode.

a regression unit test was added to cover this scenario:

  • set a known cursor position in main buffer
  • enter alt buffer
  • send decstr
  • leave alt buffer
  • verify cursor restores to the original main buffer position

validation steps performed

  • built unit test target containing Conhost.Unit.Tests.dll
  • ran targeted taef tests:
packages\Microsoft.Taef.10.100.251104001\build\Binaries\x64\TE.exe bin\x64\Debug\Conhost.Unit.Tests.dll /name:*VtSoftResetAltBufferCursorState* /unicodeoutput:false
packages\Microsoft.Taef.10.100.251104001\build\Binaries\x64\TE.exe bin\x64\Debug\Conhost.Unit.Tests.dll /name:*VtSoftResetCursorPosition* /unicodeoutput:false
packages\Microsoft.Taef.10.100.251104001\build\Binaries\x64\TE.exe bin\x64\Debug\Conhost.Unit.Tests.dll /name:*TestAltBufferCursorState* /unicodeoutput:false

Copy link
Copy Markdown
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.

Image

this type of diff which changes the line endings of entire files is, unfortunately, unacceptable. Please use a text editor that will respect the existing line endings in this repo.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Mar 30, 2026
@aarushisingh04 aarushisingh04 force-pushed the fix/19918-decstr-alt-screen-buffer-main branch from caac812 to 4cf71d3 Compare April 1, 2026 18:37
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 1, 2026
@aarushisingh04
Copy link
Copy Markdown
Author

aarushisingh04 commented Apr 1, 2026

@DHowett apologies, it has been addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DECSTR was incorrectly handled inside the Alternate Screen Buffer

2 participants