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 better extension of the search UI #186776

Closed
tpavlu opened this issue Jun 30, 2023 · 5 comments
Closed

Allow better extension of the search UI #186776

tpavlu opened this issue Jun 30, 2023 · 5 comments
Assignees
Labels
feature-request Request for new features or functionality

Comments

@tpavlu
Copy link

tpavlu commented Jun 30, 2023

I was trying to build out some features to extend the search results UI since it is a very natural place for the work I was doing.
In general there were two limitations I encountered 1 that has been flagged and delayed and 1 that has not.

  1. Context menu actions or additional action buttons like replace are not able to be added.
    Being able to add context menu actions to search can enable workflows that are more context specific to that result but possibly more intelligent. For instance being able to right click a result and look at the quick actions for that result inline.

What if we wanted to add an option for each result to process it in some way, say convert it to a functional component from a class component? If we could have a way to specify when a result matches some criteria show this additional action it would be awesome. Enabling the context menu would also achieve this.

  1. Replacements are 1:1 with find, it would be very powerful if you could instead suggest a custom replacement for each found result in the API.

When triggering the command workbench.action.findInFiles you are allowed to pass a replace value. This value has all the power of the UI's replace field but is pretty limiting when trying to build a stronger tool here. It would be awesome if you could provide one of the following as well

Pass a replacement function

replace: string | async (current: string) => string

This function could be executed when rendering the UI for the replacement and would allow a custom replacement to be computed from the original. This means you could have all the power of javascript to compute these replacements instead of being limited to only regex style computations.

You could load the file into an AST and make a decision for instance?

Allow re-use of the existing search UI

If you allowed instead for the extension to just provide a list of results it would keep a similar UI experience but provide
similar power.

		vscode.commands.executeCommand('workbench.action.showInFindAndReplace', {
		    query: { type: 'custom', representation: "AST Query" },
		    results: [{
		       match: { file: './file.ts', line: 24, start: 0, end: 1 },
		       replacement: "foo"
		    }],
		    triggerSearch: true,
		    preserveCase: true,
		    useExcludeSettingsAndIgnoreFiles: true,
		    isRegex: true,
		    isCaseSensitive: false,
		    matchWholeWord: false,
		    filesToInclude: "./**/*.ts,./**/*.tsx",
		  })

This could be made even more powerful if you actually let extension developers leverage the search functionality in the extension as well. Something like

		vscode.commands.executeCommand('workbench.action.findInFiles', (matches: Match[]) => ({
		    query: { type: 'custom', representation: "AST Query" },
		    results: matches.map(v => computeReplacement(match)),
		    triggerSearch: true,
		    preserveCase: true,
		    useExcludeSettingsAndIgnoreFiles: true,
		    isRegex: true,
		    isCaseSensitive: false,
		    matchWholeWord: false,
		    filesToInclude: "./**/*.ts,./**/*.tsx",
		  }))
@andreamah
Copy link
Contributor

andreamah commented Jul 4, 2023

If I understand correctly, this seems to boil down to two things. Please let me know if I'm correct in my understanding.

  • Allowing extensions to contribute functions that would run on text to provide a replace string (perhaps using the context menu to select this special replace, and/or in the commands).
  • Allow extensions to provide text results.

For the latter, I think we have #59921 tracking the TextSearchProvider, which might fit what you're looking for.

@andreamah andreamah added the info-needed Issue requires more information from poster label Jul 4, 2023
@tpavlu
Copy link
Author

tpavlu commented Jul 5, 2023

Yea TextSearchProvider looks like a good step to solving the second point. It would be ideal if the results could at least define a proposed replacement value tho I don't see that in the proposed API.

@andreamah andreamah added feature-request Request for new features or functionality and removed info-needed Issue requires more information from poster labels Jul 5, 2023
@VSCodeTriageBot VSCodeTriageBot added this to the Backlog Candidates milestone Jul 5, 2023
@VSCodeTriageBot
Copy link
Collaborator

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@VSCodeTriageBot
Copy link
Collaborator

This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@VSCodeTriageBot
Copy link
Collaborator

🙁 In the last 60 days, this feature request has received less than 20 community upvotes and we closed it. Still a big Thank You to you for taking the time to create this issue! To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@VSCodeTriageBot VSCodeTriageBot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

3 participants