search: heuristic whitespace and paren handling for and/or queries
Created by: rvantonder
Before this change, the parser had a heuristic way of interpreting potential search patterns like foo(bar)
, where the parentheses would be interpreted as part of the search pattern (#9494).
But, this heuristic doesn't work if the search pattern contains spaces between paren groups. So a pattern like:
(foo(bar, baz))
would imply a concatenation foo bar, baz
in the traditional way. This PR expands the heuristic to now detect these cases and interpret parentheses literally in the presence of whitespace. The gist is that we interpret it as a pattern as long as the pattern doesn't contain and
or or
operators, or parameters like repo:foo
.
Note again this is a convenience heuristic--patterns can be enclosed in quotes to disambiguate. But the convenience is important, because there's no real reason to force users to quote patterns when we can detect unambiguous cases (except that this is
In next PRs I will:
- separate test cases for parsing with/without the heuristic
- Add/fix proper scanner code, I've been taking shortcuts