remote - allow to open files from user home with tilde syntax (#83213)

This commit is contained in:
Benjamin Pasero
2020-01-14 10:15:58 +01:00
parent 2d1e215598
commit 5dfa261ced
5 changed files with 34 additions and 36 deletions

View File

@@ -9,6 +9,8 @@ import { URI } from 'vs/base/common/uri';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { Schemas } from 'vs/base/common/network';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
const REMOTE_PATH_SERVICE_ID = 'remotePath';
export const IRemotePathService = createDecorator<IRemotePathService>(REMOTE_PATH_SERVICE_ID);
@@ -16,8 +18,10 @@ export const IRemotePathService = createDecorator<IRemotePathService>(REMOTE_PAT
export interface IRemotePathService {
_serviceBrand: undefined;
path: Promise<path.IPath>;
readonly path: Promise<path.IPath>;
fileURI(path: string): Promise<URI>;
readonly userHome: Promise<URI>;
}
/**
@@ -29,7 +33,8 @@ export class RemotePathService implements IRemotePathService {
private _extHostOS: Promise<platform.OperatingSystem>;
constructor(
@IRemoteAgentService readonly remoteAgentService: IRemoteAgentService
@IRemoteAgentService private readonly remoteAgentService: IRemoteAgentService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
) {
this._extHostOS = remoteAgentService.getEnvironment().then(remoteEnvironment => {
return remoteEnvironment ? remoteEnvironment.os : platform.OS;
@@ -76,6 +81,16 @@ export class RemotePathService implements IRemotePathService {
fragment: ''
});
}
get userHome(): Promise<URI> {
return this.remoteAgentService.getEnvironment().then(env => {
if (env) {
return env.userHome;
}
return URI.from({ scheme: Schemas.file, path: this.environmentService.userHome });
});
}
}
registerSingleton(IRemotePathService, RemotePathService, true);