Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extensions to control order of FileSearch results #83462

Closed
pelmers opened this issue Oct 28, 2019 · 4 comments
Closed

Allow extensions to control order of FileSearch results #83462

pelmers opened this issue Oct 28, 2019 · 4 comments
Assignees
Labels
api api-proposal feature-request Request for new features or functionality search Search widget and operation issues
Milestone

Comments

@pelmers
Copy link
Contributor

pelmers commented Oct 28, 2019

Currently the 'proposed' API lets extensions provide file search results with a list of URIs:

export interface FileSearchProvider {
/**
* Provide the set of files that match a certain file path pattern.
* @param query The parameters for this query.
* @param options A set of options to consider while searching files.
* @param token A cancellation token.
*/
provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): ProviderResult<Uri[]>;
}

However the results are re-ordered in openAnythingHandler:

// Sort
const compare = (elementA: QuickOpenEntry, elementB: QuickOpenEntry) => compareItemsByScore(elementA, elementB, query, true, QuickOpenItemAccessor, this.scorerCache);
const viewResults = arrays.top(mergedResults, compare, OpenAnythingHandler.MAX_DISPLAYED_RESULTS);

The problem is my file search results are already sorted by my relevance metric, but our extension has no control over how they are displayed.

Idea: Add score parameter to the proposed API return value, so it would become {uri: Uri, score: number}[], and use the score when displaying results

Similar to #73904

@vscodebot
Copy link

vscodebot bot commented Oct 28, 2019

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@roblourens
Copy link
Member

Yes, I would definitely like to allow search providers to control the ordering of matches

@roblourens roblourens added this to the Backlog milestone Oct 29, 2019
@roblourens roblourens added api search Search widget and operation issues labels Oct 29, 2019
@pelmers
Copy link
Contributor Author

pelmers commented Oct 29, 2019

If someone were to contribute this change, do you have any suggestions on the new API signature?

Would it need to be backwards-compatible or could it use a new type?

@roblourens
Copy link
Member

roblourens commented Oct 30, 2019

I kind of like the idea of just including an optional 'score' on the result. The questions I have are

  • Should it be per-provider or per-response? In other words, would a provider ever do its own sorting for one request and let vscode sort for another request? Alternatively when the provider is registered, it could have a set of options or "capabilities" that enables or disables sorting for all calls to that provider
  • Pros/cons of giving a "score" vs just ordering results in the order that they are returned
  • What about mixed workspaces with two folders that have different search providers. How do we sort results when one opts in to vscode's sorting and the other does its own sorting?
  • Is this relevant to text search? Can we say the scoring only happens at the file level, or are individual matches scored differently?

Anyway I am open to taking a PR for this so you can try it out. I will definitely be working on search API again at some point but can't say when exactly that will be...

@roblourens roblourens added the feature-request Request for new features or functionality label Nov 4, 2020
@pelmers pelmers closed this as completed Apr 22, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jun 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api api-proposal feature-request Request for new features or functionality search Search widget and operation issues
Projects
None yet
Development

No branches or pull requests

2 participants