-
-
Notifications
You must be signed in to change notification settings - Fork 83
Support urxvt escapes #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Can you run the Chalk benchmarks before and after this change to ensure the performance degradation is not too large? |
I'm not sure what you mean; chalk shouldn't be affected by this as Chalk doesn't use |
Forgot that we removed |
💃 |
This makes the regex really complicated. Can we make it a separate regex and then combine them programmatically instead? |
I feel like the programmatic complexity would far outweigh the regex complexity. This has the added benefit of V8 loading in the entire regex at once while parsing, which will speed up initialization. |
I'm not sure we're on the same page. This is what I was thinking: const ansiRegex = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g;
const urxvtRegex = ...;
return new RegExp(ansiRegex.source + '|' + urxvtRegex.source, 'g'),
That is IMHO a meaningless micro-optimization. |
I knew what you meant but seeing it in code makes it look better than it did in my head. Yeah I'll change it. |
@Qix- ping :) |
@sindresorhus done and done. |
Nvm, now it's done and done. Rebased. |
Fixes chalk/strip-ansi#10.
As I mentioned over there these are annoyingly different escape codes.
This PR is a massive performance hit since it has to do backtracking on almost every match. There's no other way to support it, though.