Skip to content

search: closing parens terminate quoted patterns

Created by: rvantonder

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

Merge request reports

Loading