Searching
GitSeeker looks for all occurences in all indexed files. This includes:
- The file content
- The file path
- The file name
- Symbols generated from the the file content
Search Modes
Default
The default mode behaves like a simple case insensitive SQL WHERE column LIKE %query%
query. This means that the standard search matches literal patterns exactly, including punctuation like quotes.
Regex
The regular expression mode can be toggled using the button next to the search bar
Search Filters
Typing "file", "path" or "repo" and then hitting the tab button can be used to further narrow down the results
The filters work in AND mode, repeating a filter works in OR mode, so repo:foo repo:bar file:.php <searchterm>
is interpreted as (repo:foo OR repo:bar) AND file:php AND .....
Case sensitivity
Searching can be done case sensitive or case insensitive, both for default and regex search.
Limitations
- A maximum of MAX_RESULTS search results will be shown
- A maximum of MAX_RESULTS matches per search result will be shown
- Code fragements between multiple matches in the same line longer than COLLAPSE_THRESHOLD will be shown as "..."
- A search query in the default mode must be at least 2 characters long
Syntax Highlighting
Syntax highlighting is done serverside using highlight.js
One problem I had to overcome is that highlight.js auto-detection is quite slow because it tries to highlight the code snippet using every language it has and takes the best result.
Because of that, the language of a code snipped is first derived from the filename using lang-map and looked up in the list of available highlight.js modes.
Only if no match is found, syntax highlighting will use the slow auto-detection as fallback