[PR #1191] [MERGED] Support any number of leading zeros in VT parameter values #24520

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/1191
Author: @j4james
Created: 6/9/2019
Status: Merged
Merged: 6/10/2019
Merged by: @zadjii-msft

Base: masterHead: fix-leading-zeros


📝 Commits (2)

  • 688a635 Support any number of leading zeros in VT parameter values.
  • dd4f0ae Add unit tests for leading zeros in VT parameter values.

📊 Changes

2 files changed (+67 additions, -6 deletions)

View changed files

📝 src/terminal/parser/stateMachine.cpp (+14 -6)
📝 src/terminal/parser/ut_parser/OutputEngineTest.cpp (+53 -0)

📄 Description

Summary of the Pull Request

Adds support for any number of leading zeros in the parameter values of VT escape sequences. Tested manually, with Vttest, and with unit tests.

PR Checklist

  • Closes A question (not an issue) about ConPTY feature. (#358)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #358

Detailed Description of the Pull Request / Additional comments

In the StateMachine::_ActionParam and StateMachine::_ActionOscParam methods, the parser would treat any parameter number with more than 5 digits as being the maximum value. This PR add checks which prevent leading zeros from contributing to that count, so the 5 digit limit now only applies to significant digits.

Validation Steps Performed

  • I've tested in the WSL bash shell with escape sequences containing many leading zeros, e.g.:
    printf "\033[0000000032mGREEN?\033[m\n".
  • I've confirmed that the leading zeros test in Vttest now works (the last screen in the Test of cursor movements).
  • I've added a couple of unit tests in Microsoft::Console::VirtualTerminal::OutputEngineTest for both the CSI and OSC sequences.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/1191 **Author:** [@j4james](https://github.com/j4james) **Created:** 6/9/2019 **Status:** ✅ Merged **Merged:** 6/10/2019 **Merged by:** [@zadjii-msft](https://github.com/zadjii-msft) **Base:** `master` ← **Head:** `fix-leading-zeros` --- ### 📝 Commits (2) - [`688a635`](https://github.com/microsoft/terminal/commit/688a635d1617578a2d368150b0a96be5c2a2fe3e) Support any number of leading zeros in VT parameter values. - [`dd4f0ae`](https://github.com/microsoft/terminal/commit/dd4f0ae1c0fa1113ac3d45881d947eff1438e9ae) Add unit tests for leading zeros in VT parameter values. ### 📊 Changes **2 files changed** (+67 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/terminal/parser/stateMachine.cpp` (+14 -6) 📝 `src/terminal/parser/ut_parser/OutputEngineTest.cpp` (+53 -0) </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Adds support for any number of leading zeros in the parameter values of VT escape sequences. Tested manually, with [Vttest](https://invisible-island.net/vttest/), and with unit tests. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #358 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed * [ ] Requires documentation to be updated * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #358 <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments In the `StateMachine::_ActionParam` and `StateMachine::_ActionOscParam` methods, the parser would treat any parameter number with more than 5 digits as being the maximum value. This PR add checks which prevent leading zeros from contributing to that count, so the 5 digit limit now only applies to _significant_ digits. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed * I've tested in the WSL bash shell with escape sequences containing many leading zeros, e.g.: `printf "\033[0000000032mGREEN?\033[m\n"`. * I've confirmed that the leading zeros test in [Vttest](https://invisible-island.net/vttest/) now works (the last screen in the _Test of cursor movements_). * I've added a couple of unit tests in `Microsoft::Console::VirtualTerminal::OutputEngineTest` for both the CSI and OSC sequences. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:03:47 +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#24520