Support non-regexp search queries smartly (ie if query isn't a valid regexp)
Created by: sqs
Some users are initially confused or annoyed by Sourcegraph's search syntax, in that it interprets queries as regexps by default. There is an opportunity for us to treat queries as "regexps-if-they-are-valid-regexps-otherwise-do-some-smart-thing".
A couple examples: "as a user, if I ____"
- paste
myFuncName(
into the query box, I obviously would prefer it to auto-escape the(
-- this is easy (in theory) because as-is it is not a valid regexp, so we can interpret it as a literal string - type
file:*.go
, I intend to look for matches in Go files (ie interpret myfile:
query as a glob and translate it intofile:\.go$
) -- again, this is easy because*.go
is not a valid regexp, so we can munge it
The risk is that it muddies users' understanding of what input is expected. We can mitigate this by telling the users that we auto-corrected their query, as in:
One other possibility (IMO not as good as the one above) is to show instant feedback when there are errors: