fix: humanizeKeySequences should not replace standalone ESC byte #44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
humanizeKeySequences()in@inquirerer/testto not replace standalone ESC bytes (\u001b), which was breaking ANSI code stripping in downstream consumers.The standalone ESC byte is the start of all ANSI escape codes (e.g.,
\u001b[97mfor white text). WhenhumanizeKeySequences()replaced\u001bwith<ESCAPE>, it converted ANSI codes like\u001b[97minto<ESCAPE>[97m, whichcleanAnsi()could no longer strip. This caused test snapshots in constructive to contain raw ANSI styling codes instead of clean output.The fix:
Recordto ordered array to ensure longer sequences (like\u001b[Afor UP_ARROW) are replaced before shorter ones could interfereReview & Testing Checklist for Human
<ESCAPE>in outputpackages/cli/__tests__/cli.test.tsnow pass with clean ANSI-stripped outputTest plan: After merging and publishing, update constructive's
@inquirerer/testdependency and runpnpm testinpackages/clito verify snapshots no longer contain ANSI escape codes.Notes
This is a prerequisite fix for migrating constructive's test utilities to use
@inquirerer/test. The migration PR in constructive is blocked on this fix being published.Link to Devin run: https://app.devin.ai/sessions/e5018850caff45ce8a126331548d69bc
Requested by: Dan Lynch (@pyramation)