Skip to content

Commit

Permalink
Merge pull request #543 from urbanfly/feature/avoid-zip-errors
Browse files Browse the repository at this point in the history
Avoid registering the same scheme multiple times
  • Loading branch information
DavyLandman authored Jan 23, 2025
2 parents 47445f3 + 47035a7 commit 6f591ab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
32 changes: 22 additions & 10 deletions rascal-vscode-extension/src/fs/RascalFileSystemProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,31 @@ export class RascalFileSystemProvider implements vscode.FileSystemProvider {
});
}



registerSchemes(schemes:string[]):void {
/**
* Attemptes to register all schemes.
* @param schemes The list of schemes to register for this provider
*/
tryRegisterSchemes(schemes: string[]) {
schemes
.filter(s => !this.protectedSchemes.includes(s))
// we add support for schemes that look inside a jar
.concat(schemes
.filter(s => s !== "jar" && s !== "zip" && s !== "compressed")
.map(s => "jar+" + s))
.filter(isUnknownFileSystem)
.forEach(s => vscode.workspace.registerFileSystemProvider(s, this));
// we add support for schemes that look inside a jar
schemes
.filter(s => s !== "jar" && s !== "zip" && s !== "compressed")
.map(s => "jar+" + s)
.filter(isUnknownFileSystem)
.forEach(s => vscode.workspace.registerFileSystemProvider(s, this));
.forEach(s => {
try {
vscode.workspace.registerFileSystemProvider(s, this);
this.client.debug(`Rascal VFS registered scheme: ${s}`);
} catch (error) {
if (isUnknownFileSystem(s)) {
this.client.error(`Unable to register scheme: ${s}\n${error}`);
}
else {
this.client.debug(`Rascal VFS lost the race to register scheme: ${s}, which in most cases is fine`);
}
}
});
}

watch(uri: vscode.Uri, options: { recursive: boolean; excludes: string[]; }): vscode.Disposable {
Expand Down
3 changes: 1 addition & 2 deletions rascal-vscode-extension/src/lsp/RascalLSPConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ export async function activateLanguageClient(

schemesReply.then( schemes => {
vfsServer.ignoreSchemes(schemes);
new RascalFileSystemProvider(client).registerSchemes(schemes);
new RascalFileSystemProvider(client).tryRegisterSchemes(schemes);
});


return client;
}

Expand Down

0 comments on commit 6f591ab

Please sign in to comment.