Add support for workspace read requests - #1825
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
@microsoft-github-policy-service agree |
a97888f to
d0e4f81
Compare
Dirk Bäumer (dbaeumer)
left a comment
There was a problem hiding this comment.
Thanks. Very nice PR.
| /** | ||
| * Whether the file is a symbolic link. | ||
| */ | ||
| isSymlink: boolean; |
There was a problem hiding this comment.
Can we make this a flag property with a bit wise implementation. Makes it easier to expand in the future.
There was a problem hiding this comment.
I thought about combining it with the type property, similar to how its done in vscode, but decided against it. Is this what you had in mind?
There was a problem hiding this comment.
Mark Sujew (@msujew) no, I like that they are separate but I would rename isSymlink to flags and have a SymLink flag. If we have more flags in the future it is easier to extend.
There was a problem hiding this comment.
Ok, I believe that's what I've done in b356b60 already 👍
| /** | ||
| * Whether the entry is a symbolic link. | ||
| */ | ||
| isSymlink: boolean; |
|
What if we read a file that is binary? I have some library files and we need to obfuscate the source for end-users. const fileRead: FileSystemReadFileSignature = async (uri, encoding) => {
try {
const bytes = await vscode.workspace.fs.readFile(uri);
const decoder = new TextDecoder(encoding || 'utf-8');
return decoder.decode(bytes);
} catch {
return null;
}
};Does it make sense when I currently am already testing with this pull request and all works fine. But I have used middleware to overwrite the implementation. (Which is also fine for me) |
Martijn Bakker (@Bakker-Martijn) WDYT about Dirk Bäumer (@dbaeumer) do you have an opinion on this? |
|
Mark Sujew (@msujew) I had the same thought process. But this is not allowed: https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings I believe the I also notices the size increase. Which is not ideal... Just wanted to point this out. It also depends if binary files will be read by other languages servers or not (perhaps I am one of the few). Can imagine not implementing this, having the middleware as fallback is also OK for me. --Edit: |
Yes, exactly. Essentially just special casing the client code and documenting this into the protocol. I.e. servers can request binary file content via |
|
That would be perfect for my use-case. I think that is an excellent idea :) |
Related to microsoft/language-server-protocol#1264 (does not fully resolve it, since this PR does not include features to write into a file system - only read from it).
Adds support for the server to read files/directories/stat info from the client.
As indicated by microsoft/language-server-protocol#1264 (comment), I also thought it'd be best to start with read-only access to the file system. However, the new interfaces/types should be extendable enough to also add write requests if required later on.
Some questions/considerations:
null. Should it return a response error instead?FileSystemClientCapabilities. Does it make sense to expose each individual request type as an opt-in flag? Or is it enough to provide aread?: booleanflag (maybe extend this with awrite?: booleanflag later on)?FileType.unknownvalue results from the fact that vscode offersvscode.FileType.unknownas a possible value to return forFileStat.type. Should this be included in the protocol, or should stats/directory entries with this type simply be omitted?