[PR #17194] Prevent the VT engine painting unnecessarily #31155

Open
opened 2026-01-31 09:45:28 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/17194

State: closed
Merged: Yes


When the VT render engine starts a paint operation, it first checks to
see whether there is actually something to do, and if not it can end the
frame early. However, the result of that check was being ignored, which
could sometimes result in an unwanted SGR reset being written to the
conpty pipe.

This was particular concerning when passing through DCS sequences,
because an unexpected SGR in the middle of the DCS string would
cause it to abort early.

This PR addresses the problem by making sure the VtEngine::StartPaint
return value is appropriately handled in the XtermEngine class.

Detailed Description of the Pull Request / Additional comments

To make this work, I also needed to correct the _cursorMoved flag,
because that is one of things that determines whether a paint is needed
or not, but it was being set in the InvalidateCursor method at the
start of ever frame, regardless of whether the cursor had actually
moved.

I also took this opportunity to get rid of the _WillWriteSingleChar
method and the _quickReturn flag, which have been mostly obsolete for
a long time now. The only place the flag was still used was to optimize
single char writes when line renditions are active. But that could more
easily be handled by testing the _invalidMap directly.

Validation Steps Performed

I've confirmed that the test case in issue #17117 is no longer aborting
the DCS color table sequence early.

Closes #17117

**Original Pull Request:** https://github.com/microsoft/terminal/pull/17194 **State:** closed **Merged:** Yes --- When the VT render engine starts a paint operation, it first checks to see whether there is actually something to do, and if not it can end the frame early. However, the result of that check was being ignored, which could sometimes result in an unwanted `SGR` reset being written to the conpty pipe. This was particular concerning when passing through `DCS` sequences, because an unexpected `SGR` in the middle of the `DCS` string would cause it to abort early. This PR addresses the problem by making sure the `VtEngine::StartPaint` return value is appropriately handled in the `XtermEngine` class. ## Detailed Description of the Pull Request / Additional comments To make this work, I also needed to correct the `_cursorMoved` flag, because that is one of things that determines whether a paint is needed or not, but it was being set in the `InvalidateCursor` method at the start of ever frame, regardless of whether the cursor had actually moved. I also took this opportunity to get rid of the `_WillWriteSingleChar` method and the `_quickReturn` flag, which have been mostly obsolete for a long time now. The only place the flag was still used was to optimize single char writes when line renditions are active. But that could more easily be handled by testing the `_invalidMap` directly. ## Validation Steps Performed I've confirmed that the test case in issue #17117 is no longer aborting the `DCS` color table sequence early. Closes #17117
claunia added the pull-request label 2026-01-31 09:45:28 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31155