search: decorate event stream result
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")
-
I'm at the junction where I need converted line matches to extract subparts of the highlighted content, so will tackle that in a separate PR: https://github.com/sourcegraph/sourcegraph/pull/24537
-
Once that's done, can hook up the URL arguments, parsed in https://github.com/sourcegraph/sourcegraph/pull/24536.
old notes
-
Started off implementing a
Decorate()method on file match. We can't have that though, because we can't call highlight code frominternal/search(OK, reasonable). I thought, "should highlight code be ininternal/searchand I think the answer here is "no", it is suited to live incmd/frontend/internal, since we should think of this decoration service happening in frontend. Conclusion: I'm exposingDecorate()as a function that takes anFileMatchresult in highlight code infrontend/internal -
Added a
FetchContentmethod tofmresult type. Don't know if we should expandfmresult type with this method, or just have theDecoratefunction do all of thegit/fetchinstead once it gets anfm. In the context ofcomputemethod, it would be handier to have aFetchContentmethod (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 andcomputecode 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