Skip to content

search: decorate event stream result

Administrator requested to merge rvt/stream-highlight-ranges into main

Created by: rvantonder

Should be good for this part, just an open question around timeout values/ctx and delineating ("successfully marked up HTML", "plaintext HTML" fallback, and "no highlighting")

old notes
  • Started off implementing a Decorate() method on file match. We can't have that though, because we can't call highlight code from internal/search (OK, reasonable). I thought, "should highlight code be in internal/search and I think the answer here is "no", it is suited to live in cmd/frontend/internal, since we should think of this decoration service happening in frontend. Conclusion: I'm exposing Decorate() as a function that takes an FileMatch result in highlight code in frontend/internal

  • Added a FetchContent method to fm result type. Don't know if we should expand fm result type with this method, or just have the Decorate function do all of the git/fetch instead once it gets an fm. In the context of compute method, it would be handier to have a FetchContent method (for rewriting results and data output) than inlining that content fetching into the highlight code. But, a small duplication of content fetching in both of highlight code and compute code is not that big of a deal either.

  • Just calls highlight on the entire file contents, no range splitting based on line matches yet.

  • Inline comments about TODOs and stubbed values.


Example invocation:

https://sourcegraph.test:3443/search/stream?t=literal&display=500&q=test

you'll see:

"repository":"github.com/Andoryuuta/NotSourcegraph","repoStars":6,"repoLastFetched":"2021-09-01T18:55:36.296464Z","branches":[""],"version":"df369f92e49de04cfbbf639e564a4e929d1a9f65","Content":[{"Value":{"Plaintext":"","HTML":"\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class=\"line\" data-line=\"1\"/\u003e\u003ctd class=\"code\"\u003e\u003cdiv\u003e\u003cspan class=\"hl-source hl-python\"\u003e\u003cspan class=\"hl-meta hl-statement hl-import hl-python\"\u003e\u003cspan class=\"hl-keyword hl-control hl-import hl-python\"\u003eimport\u003c/span\u003e \u003cspan class=\"hl-meta hl-qualified-name hl-python\"\u003e\u003cspan class=\"hl-meta hl-generic-name hl-python\"\u003ecv2\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\n\u003c/span\u003e\u003c/div\u003e\u003c/td\u003e\u003c/tr blha blah blabh

Merge request reports

Loading