search: highlight repository matches in RepoSearchJob#41470
Conversation
For literal patterns, regex meta characters are escaped in ToBasic().PatternString() so don't escape them again
…h on the same repo
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff aa0b3fe...9d076e4.
|
limitedmage
left a comment
There was a problem hiding this comment.
Frontend changes look good!
There was a problem hiding this comment.
Agree that it's not ideal 😄 Seems really strange for the ranges returned from the API to not actually be directly applicable to the repo names. How difficult would it be to change the ranges when we trim the code host in the client?
There was a problem hiding this comment.
How difficult would it be to change the ranges when we trim the code host in the client?
I don't know, I thought about it briefly, but it seemed like it would be potentially more intrusive than just doing this. 🙈 I don't expect that we're going to change how we display repo names anytime soon which made me feel better about going this route
There was a problem hiding this comment.
I don't think this should be a blocker, but I do think it's worth looking into. If you're not going to dig into this immediately, could you open a github issue for it? This feels like it's happening on the wrong layer, and that becomes more important if we ever have other consumers like Code Insights using this. We're running into issues like this left and right with code insights right now, so I'd rather not add more 🙂
There was a problem hiding this comment.
Opened this issue https://github.com/sourcegraph/sourcegraph/issues/41476
There was a problem hiding this comment.
Is this condition correct? Consider repo:contains.path(abc) and repo:def. Don't we still want to highlight def?
There was a problem hiding this comment.
I think it is correct, for something like repo:contains.path(abc) and repo:def there will only be one RepoSearchJob and path will be appended to RepoOptions.HasFileContent for that job. So there shouldn't need to be merging of results since that repo will only be found once
There was a problem hiding this comment.
oh wait, maybe not. stand by
There was a problem hiding this comment.
Okay never mind, this condition should be right, but there are some other places in the search backend outside of RepoSearchJob where we return a RepoMatch and if one of those paths is hit, that repo match will not be highlighted. Will follow up to address that
There was a problem hiding this comment.
for something like repo:contains.path(abc) and repo:def there will only be one RepoSearchJob
Yes, you're right -- bad example 😄
But what about repo:contains.path(abc) or repo:def (which also uses the merger)? I think we still want the highlights from repo:def even if the result we're merging into has no highlights.
There was a problem hiding this comment.
Yes indeed, removed the if check
5d77148 to
7fdde69
Compare
Part of #18374
As part of
RepoSearchJobexecution, get the ranges of the repo name that match any ofRepoOpts.RepoFilters, and return those ranges to the client to be highlighted on repository match results.Test plan
Added unit test
Manual testing to feel good about the addition
CI