search frontend: detect and highlight patterns in query
There are no commits yet
Push commits to the source branch or add previously merged commits to review them.
Created by: rvantonder
Patterns now highlight wherever they are used, based on patterntype
, if set in the query string. Example Code Insights page:
Before:
After:
The query highlighter doesn't take a parameter to know how to highlight patterns (so I can't tell whether to highlight .*
as regex or not). This PR adds an optional parameter so it can force highlighting on the patterntype if it's explicitly added.
But that's not enough, because everything that uses the query highlight component today doesn't set the patterntype (because it doesn't exist), so there's no way to just add highlighting, unless... well, if those queries happen to specify patterntype
in the query string, then we can detect it.
So now:
we detect patterntype
in the query string and tokenize based on that value if it exists. it means scanning every twice is unavoidable. this is the cost of making a decision to include a value inside a string that defines how that string itself should be interpreted. bad decision and the bane of patterntype
if we don't detect patterntype
in the query string, and the query highlighter is not told how to scan/highlight the query, then it scans/highlights as literal. When https://github.com/sourcegraph/sourcegraph/pull/38141 is merged it will scan/highlight as standard.
Added test.
Check out the client app preview documentation to learn more.
Push commits to the source branch or add previously merged commits to review them.