Skip to content

Improve detection of line boundary assertions (Part 1 for issue #116445) #116823

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

IllusionMH
Copy link
Contributor

@IllusionMH IllusionMH commented Feb 17, 2021

This PR fixes #116445

Currently ^ inside of character class [^a] will be detected in assumption that it's line boundary assertion, but it actually has different meaning.

This PR provides more precise detection of line boundary assettions as an example which will provide adequate behavior in case of #116445.

However I think that this check should be removed completely and next match search position should be propagated by 1 column (when possible, or to next line at the end of the string) because existence of start of line assertion may not be triggered at all if it's in specific branch.

Pathological case

[...`123.23.3.123`.matchAll(/(?<=^|2?)\d*(?=$|2?)/g)]
[    
    ["123", index: 0, input: "123.23.3.123", groups: undefined],
    ["", index: 3, input: "123.23.3.123", groups: undefined],
    ["23", index: 4, input: "123.23.3.123", groups: undefined],
    ["", index: 6, input: "123.23.3.123", groups: undefined],
    ["3", index: 7, input: "123.23.3.123", groups: undefined],
    ["", index: 8, input: "123.23.3.123", groups: undefined],
    ["123", index: 9, input: "123.23.3.123", groups: undefined]
]

Will investigate if it's possible to remove check at all and if there are more cases hen even precise boundary check wont help.
Then will add corresponding tests.

@rebornix would love to hear whe do you think about removing checks like this one completely.
https://github.com/microsoft/vscode/pull/116823/files#diff-4bd68ef6798b8b4aea76c65b352d49515f4adfc9fce8d1d33b0b2963bfab2e58R256-R259

@IllusionMH IllusionMH changed the title Improve detection of line boundary assertions Improve detection of line boundary assertions (Part 1 for issue #116445) Feb 17, 2021
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.

find not working correctly for regular expression containing asterisk wildcard
2 participants