mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
util.stripVTControlCharacters ran Node's ANSI pattern through the regex replace loop, which tried the OSC branch's lazy scan at every introducer. Text with many unterminated OSC introducers took quadratic time (about 200 s for 100,000 of them). The function now scans once and gives the same result as Node 24.22's pattern: the OSC branch ends at the first terminator after ESC ], and that position is cached across introducers; the CSI branch resolves its first match without backtracking. A removal that brings lone surrogates together keeps canonical storage. Corpus programs 5470-5474 cover OSC and CSI forms, seeded random input, long unterminated runs and surrogates, and strip-vt-linear.test.ts checks that 400,000 unterminated introducers finish quickly.