use set to store and lookup paths of interest

This commit is contained in:
Jan Kretschmer
2021-11-20 00:16:06 +01:00
parent b074018c3e
commit 8779aaf2ae
2 changed files with 21 additions and 20 deletions

View File

@@ -21,18 +21,19 @@ export namespace FsReadDirRequest {
export function serveFileSystemRequests(client: CommonLanguageClient, runtime: Runtime, subscriptions: { dispose(): any }[]) {
subscriptions.push(client.onRequest(FsContentRequest.type, (param: { uri: string; encoding?: string; }) => {
const uri = Uri.parse(param.uri);
if (uri.scheme === 'file' && runtime.fs) {
return runtime.fs.getContent(param.uri);
}
return workspace.fs.readFile(uri).then(buffer => {
return new runtime.TextDecoder(param.encoding).decode(buffer);
}, () => {
// this path also considers TextDocumentContentProvider
if (uri.scheme === 'file') {
if (runtime.fs) {
return runtime.fs.getContent(param.uri);
} else {
return workspace.fs.readFile(uri).then(buffer => {
return new runtime.TextDecoder(param.encoding).decode(buffer);
});
}
} else {
return workspace.openTextDocument(uri).then(doc => {
return doc.getText();
});
});
}
}));
subscriptions.push(client.onRequest(FsReadDirRequest.type, (uriString: string) => {
const uri = Uri.parse(uriString);