Skip to content

Search backend: Enable multi-line matches

Warren Gifford requested to merge cc/multiline-hacking into main

Created by: tbliu98

This PR introduces the MultilineMatch type and transitions result.FileMatch to use that instead of LineMatch.

Change overview:

  • Introduce the MultilineMatch type
  • Replace FileMatch.LineMatches with FileMatch.MultilineMatches in the search backend
  • Provide methods AsLineMatches(), AsMultilineMatches(), and MultilineSliceAsLineMatchSlice() to convert between LineMatch and MultilineMatch, so other services which still rely on LineMatch can remain unchanged for now
  • Fix result limiting, which previously did not limit symbol results at all

A noteworthy thing here is that we can birectionally convert between LineMatch and MultilineMatch. The important thing about this is that we can start using MultilineMatch throughout the frontend process without changing any of the APIs into or out of frontend. That then allows us to merge this change independently from any changes to zoekt, searcher, gitserver, or search clients. Yay!

The next steps will be to update the search backends (particularly zoekt and searcher) to return multiline matches. Following that, we we update the GraphQL and streaming APIs to return multiline matches and deprecate the LineMatch API.

This PR depends on a change to Comby, so cannot be merged until the sourcegraph deployment has been updated to use that version.

Test plan

Unit tests for new functionality. Manually verify correct preview and highlight range for multi-line structural and regex search results.

Merge request reports

Loading