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

Tweak nonewlines regex rewriting (#211) #212

Merged
merged 2 commits into from
Oct 5, 2018

Conversation

robinst
Copy link
Collaborator

@robinst robinst commented Oct 4, 2018

Using \n+ in a regex doesn't make any sense for Sublime Text syntaxes, but let's not produce an invalid regex in that case.

Using \n+ in a regex doesn't make any sense for Sublime Text syntaxes,
but let's not produce an invalid regex in that case.
// Replacing `\n` with `$` in `\n?` or `\n+` would make parsing later fail
// with "target of repeat operator is invalid"
let c3 = self.peek();
if c2 == b'n' && c3 != Some(b'?') && c3 != Some(b'+') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to also check for * here, as \n* -> $* would also be invalid

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, done!

@trishume trishume merged commit 51208d3 into master Oct 5, 2018
@trishume trishume deleted the issue-211-tweak-regex-rewrite branch October 5, 2018 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants