Skip to content
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

Fix regex patterns allowing for empty strings #7281

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

chrisduerr
Copy link
Member

This patch changes the mode we search for patterns which allow an empty string, by anchoring all searches. As a result we will match the longest possible match when multiple patterns are present (like ;*|rust), instead of using the leftmost pattern only.

This is only possible with empty matches since our parser is reset on every byte anyway, so anchoring the search makes no difference.

Closes #7276.


In theory this would allow us to split the parsers (so regex_search_internal) completely for empty and non-empty patterns. This would probably speed up the non-empty version but I'm not sure it is worse the mess.

This patch changes the mode we search for patterns which allow an empty
string, by anchoring all searches. As a result we will match the longest
possible match when multiple patterns are present (like `;*|rust`),
instead of using the leftmost pattern only.

This is only possible with empty matches since our parser is reset on
every byte anyway, so anchoring the search makes no difference.

Closes alacritty#7276.
@kchibisov kchibisov merged commit e1859e8 into alacritty:master Oct 9, 2023
5 checks passed
@chrisduerr chrisduerr deleted the regex_rewrite_642 branch October 9, 2023 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Regex ;*|rust doesn't match anything in rustfmt string
2 participants