-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Expose VS Code extension API for telling text and binary files apart the same way VS Code does #58933
Comments
First what you need is #48034 which is about a low level file read/write API. Using
Given the things above indexing shouldn't be done in the extension host as it will likely saturate the process and prevent other extension logic from executing. |
closing as double dupe |
Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines. Happy Coding! |
I don't understand how the language detection issue relates to this problem, sorry. For the read/write access API, I know about that issue and I will have great use for it once it lands, but I don't understand how is that supposed to tell me what VS Code considers to be a binary file and what it considers to be a text file either. I am trying to find a logic which for a given URI will determine if VS Code will be able to display that file or not. Whether we're talking about a This can stay closed, because I have found a solution for this particular extension I am working on, but in general I think it would still be useful. At the very least this is |
Language detection includes detecting if a file is binary or textual. |
I see, but from reading that issue I don't see it mentioned. Would that information be exposed to the extension API or would we get either langues is X or language is unknown only? |
I have an extension which needs to index the workspace files and do additional processing for text file. The way I currently do it is to do a search for
workspace.findFiles('**/*.*')
and tryworkspace.openTextDocument
on all of the results. If an exception is caught, I consider that to be a binary file and skip it. If not, I continue with processing the file.This works, but it causes the "VS Code Marketplace has extension to help with the .random file type" kinds messages to appear for files the user has not opened (because I don't do
window.showDocument
).How can I keep indexing the workspace without causing these messages to appear? And it that is not possible, could an extension API for this detection be provided instead?
I would like to avoid trying to reimplement that detection myself as it's important for the logic to be and stay the same as VS Code, otherwise a failure to keep up with VS Code's changes to this logic will return to causing these messages to appear.
The text was updated successfully, but these errors were encountered: