[PR #16804] Add support for the DECSWT (Set Window Title) escape sequence #31001

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

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

State: closed
Merged: Yes


This PR adds support for the OSC 21 sequence used on DEC terminals to
set the window title. It's just an alias of the OSC 2 title sequence
used by XTerm.

This PR also corrects the handling of blank title sequences, which are
supposed to reset the title to its default value, but were previously
ignored.

Detailed Description of the Pull Request / Additional comments

To handle the blank title parsing correctly, I had to make some changes
to the state machine. Previously it would not have dispatched an OSC
sequence unless it received a semicolon following the OSC number, but
when there's a blank string, that semicolon should not be required.

I also took this opportunity to simplify the OSC parsing in the state
machine, and eliminate the _GetOscTitle method which no longer served
any purpose.

Validation Steps Performed

I've manually confirmed that the title sequences are now working as
expected, and added some state machine unit tests covering the blank
value handling for these sequences.

I also had to update one of the existing state machine tests to account
for the changes I made to allow the semicolon to be omitted.

Closes #16783
Closes #16784

**Original Pull Request:** https://github.com/microsoft/terminal/pull/16804 **State:** closed **Merged:** Yes --- This PR adds support for the `OSC 21` sequence used on DEC terminals to set the window title. It's just an alias of the `OSC 2` title sequence used by XTerm. This PR also corrects the handling of blank title sequences, which are supposed to reset the title to its default value, but were previously ignored. ## Detailed Description of the Pull Request / Additional comments To handle the blank title parsing correctly, I had to make some changes to the state machine. Previously it would not have dispatched an `OSC` sequence unless it received a semicolon following the `OSC` number, but when there's a blank string, that semicolon should not be required. I also took this opportunity to simplify the `OSC` parsing in the state machine, and eliminate the `_GetOscTitle` method which no longer served any purpose. ## Validation Steps Performed I've manually confirmed that the title sequences are now working as expected, and added some state machine unit tests covering the blank value handling for these sequences. I also had to update one of the existing state machine tests to account for the changes I made to allow the semicolon to be omitted. Closes #16783 Closes #16784
claunia added the pull-request label 2026-01-31 09:44: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#31001