This repository was archived by the owner on Sep 30, 2024. It is now read-only.
search: closing parens terminate quoted patterns#41455
Merged
Merged
Conversation
rvantonder
commented
Sep 7, 2022
Comment on lines
+24
to
+26
| "labels": [ | ||
| "Regexp" | ||
| ], |
Contributor
Author
There was a problem hiding this comment.
the important part of the output
Contributor
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff 2d66e9c...3e1bebc.
|
tbliu98
approved these changes
Sep 7, 2022
Contributor
|
@rvantonder Just curious, does this also address https://github.com/sourcegraph/sourcegraph/issues/40511? I suspect it may be the same thing from the description |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously an expression like
(foo AND /bar/)would treat the/bar/part as a literal instead of a regular expression in standard mode. This PR fixes it to treat/bar/as a regular expression.Explanation, optional reading
This is because previous to standard mode, we didn't care whether any pattern is well-delineated (e.g., by
/.../or"...") since these terms were always literal. But when they should be well-delineated (e.g., previously only in regex mode) we had a check that such a well-delineated pattern should be followed by a recognized terminal, in this case, whitespace. We check a "followed-by" condition because that lets us be resilient to lexing e.g.,/some/thing/without the user needing to escape the inner/. But the "followed by a space" is insufficient: we also need to check a possible valid terminator)for a well-delineated regex in standard mode, before giving up and claiming the fallback case, that the pattern is a literal.It would be nice to separate out the pure token lexing at some point (similar to frontend code) because of the hybrid literal/regexp complexity in standard mode, but this change is sufficient to cover the buggy behavior.
Test plan
Added test