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

Feature Request: Add Built-in Text Search API for Extensions #191383

Closed
ykdojo opened this issue Aug 26, 2023 · 4 comments
Closed

Feature Request: Add Built-in Text Search API for Extensions #191383

ykdojo opened this issue Aug 26, 2023 · 4 comments
Assignees

Comments

@ykdojo
Copy link

ykdojo commented Aug 26, 2023

Feature Request for VS Code: Text Search API

Summary

VS Code currently lacks a built-in API for text-based search within files. While the findFiles method allows for file discovery based on glob patterns, there is no straightforward way to perform text-based searches within those files programmatically.

Problem Statement

Developers often have to resort to using Node.js file system APIs or other libraries to read file content and then apply their own search algorithms. This adds extra overhead and complexity to extensions that aim to provide advanced search features.

Proposed Solution

Introduce a new API method, tentatively named findTextInFiles, that allows for text-based search within files. This method could accept parameters like search query, file type, and directory, and return a list of matches with their respective line numbers.

Use Cases

  1. Advanced search features in custom extensions.
  2. Automated code analysis and refactoring.
  3. Enhanced navigation features.

Benefits

  • Simplifies the development process for extension developers.
  • Provides a unified way to perform text-based searches.
  • Could potentially speed up search operations by leveraging VS Code's internal optimizations.

Additional Context

This feature request aims to fill a gap in the current VS Code API and make it more robust and developer-friendly.

@ArturoDent
Copy link

ArturoDent commented Aug 28, 2023

There are two proposed api's that have been around awhile you can test now:

findTextInFiles
https://github.com/microsoft/vscode/blob/main/src/vscode-dts/vscode.proposed.findTextInFiles.d.ts

textSearchProvider
https://github.com/microsoft/vscode/blob/main/src/vscode-dts/vscode.proposed.textSearchProvider.d.ts

See if they what you want. Not a lot has happened with them lately though. There must be issues about them here.

@andreamah andreamah added the info-needed Issue requires more information from poster label Aug 28, 2023
@andreamah
Copy link
Contributor

I think the current APIs mentioned above should fulfil your use case. Please try them out and add feedback to their respective issues.
findTextInFiles - #59924
textSearchProvider - #59921

@andreamah andreamah closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2023
@andreamah andreamah removed the info-needed Issue requires more information from poster label Aug 28, 2023
@ykdojo
Copy link
Author

ykdojo commented Aug 28, 2023

Thank you @andreamah. Are they currently only available in Insiders, or is it available in all current versions of VS Code?

@ArturoDent
Copy link

They can only be used in Insiders as they are proposed apis cuurrently. To try them out see Using Proposed API.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants