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

ignore capture scopes for non consumed characters at yaml load time #215

Merged
merged 4 commits into from
Oct 13, 2018

Conversation

keith-hall
Copy link
Collaborator

Fixes #176 by re-purposing the regex re-writer to find capture groups which are not inside lookarounds. If, in a YAML syntax definition, a scope stack is applied to a capture group inside a lookaround, (i.e. captures:\n x: scope.stack goes.here where x is the number of a capture group in a lookahead/behind,) syntect will now ignore it, just like Sublime Text does. Because it does this work at YAML load time, and not parse time, the parsing speed will not be affected (or, rather, it will be slightly improved/reduced for some syntax definitions by having less capture groups to apply operations for).

@keith-hall keith-hall force-pushed the ignore_captures_in_lookarounds branch from f7f0ae5 to 42a0304 Compare October 11, 2018 12:57
Copy link
Collaborator

@robinst robinst left a comment

Choose a reason for hiding this comment

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

Looks good!

A bit unfortunate that we need to do this but I couldn't find any options in oniguruma to change the behavior. We might have to revisit when we switch to fancy-regex, we'll see :).

@@ -588,6 +596,82 @@ impl<'a> RegexRewriter<'a> {
String::from_utf8(result).unwrap()
}

fn get_consuming_capture_indexes(mut self) -> Vec<usize> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add some documentation here on what it does and why we need it? Basically what's in the PR description :).

Copy link
Owner

@trishume trishume left a comment

Choose a reason for hiding this comment

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

Looks good to me thanks!

@trishume trishume merged commit f10eb72 into trishume:master Oct 13, 2018
@keith-hall keith-hall deleted the ignore_captures_in_lookarounds branch October 13, 2018 07:57
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.

None yet

3 participants