Skip to content
Snippets Groups Projects

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

Approval is optional

Merged by avatar (Nov 17, 2025 11:40pm UTC)

Merge details

  • Changes merged into main with 3e1bebc9.
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading