google / zoekt

Fast trigram based code search
1.69k stars 113 forks source link

Is multiline search supported? #63

Closed neongreen closed 5 years ago

neongreen commented 5 years ago

Can matches span several lines? I tried something like \+\n\s on cs.chromium.com, but Zoekt kept telling me there were no search results, even though some snippets clearly match, e.g. this (the match is the last character of line 2 + the first character of line 3).

exec_script_whitelist =
    build_dotfile_settings.exec_script_whitelist +
    angle_dotfile_settings.exec_script_whitelist +

If Zoekt doesn't support this – I would appreciate any tips on where in the code I should dig to implement support for multiline matches.

hanwen commented 5 years ago

it does support multiline search,

https://cs.bazel.build/search?q=%5C%2B%5Cn%5Cs+f%3Acodesearch-gitlink-overlay%2Fthird_party%2Fangle%2F.gn&num=50

however cs.chromium.com does not exist, and cs.chromium.org uses an entirely different infrastructure which has nothing to do with zoekt, so I can't vouch for it.

In addition, if you search for +\n\s, that expands to the regex "\+\n[\t-\n\f-\r ]". Since there are no literal trigrams at all in the regular expression, it is expensive to match, and you likely don't get an exhaustive result.

try

script.*+\n\s

as query to get better filtering.

neongreen commented 5 years ago

and cs.chromium.org uses an entirely different infrastructure which has nothing to do with zoekt

Heh, I thought for some reason that it used Zoekt :/ Alright then.

however cs.chromium.com does not exist

Yeah, that's a typo.

Thanks!