Use virtual workspace scheme in path service

This commit is contained in:
Alex Ross 2021-05-07 16:36:07 +02:00
parent 2ba93b3fec
commit 25d1c0b0eb
No known key found for this signature in database
GPG key ID: 89DDDBA66CBA7840
2 changed files with 26 additions and 2 deletions

View file

@ -10,6 +10,7 @@ import { URI } from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { getVirtualWorkspaceScheme } from 'vs/platform/remote/common/remoteHosts';
export class BrowserPathService extends AbstractPathService {
@ -29,6 +30,11 @@ function defaultUriScheme(environmentService: IWorkbenchEnvironmentService, cont
return Schemas.vscodeRemote;
}
const virtualWorkspace = getVirtualWorkspaceScheme(contextService.getWorkspace());
if (virtualWorkspace) {
return virtualWorkspace;
}
const firstFolder = contextService.getWorkspace().folders[0];
if (firstFolder) {
return firstFolder.uri.scheme;

View file

@ -8,17 +8,35 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
import { IPathService, AbstractPathService } from 'vs/workbench/services/path/common/pathService';
import { Schemas } from 'vs/base/common/network';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { getVirtualWorkspaceScheme } from 'vs/platform/remote/common/remoteHosts';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
export class NativePathService extends AbstractPathService {
readonly defaultUriScheme = this.environmentService.remoteAuthority ? Schemas.vscodeRemote : Schemas.file;
readonly defaultUriScheme = defaultUriScheme(this.environmentService, this.contextService);
constructor(
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
@INativeWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService
@INativeWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService,
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService
) {
super(environmentService.userHome, remoteAgentService);
}
}
function defaultUriScheme(environmentService: IWorkbenchEnvironmentService, contextService: IWorkspaceContextService): string {
if (environmentService.remoteAuthority) {
return Schemas.vscodeRemote;
}
const virtualWorkspace = getVirtualWorkspaceScheme(contextService.getWorkspace());
if (virtualWorkspace) {
return virtualWorkspace;
}
return Schemas.file;
}
registerSingleton(IPathService, NativePathService, true);