提交 c9609bd2 编写于 作者: B Benjamin Pasero

add userHomeSync (for #94506)

上级 5a83a62a
......@@ -15,12 +15,29 @@ const REMOTE_PATH_SERVICE_ID = 'remotePath';
export const IRemotePathService = createDecorator<IRemotePathService>(REMOTE_PATH_SERVICE_ID);
export interface IRemotePathService {
_serviceBrand: undefined;
/**
* The path library to use for the target remote environment.
*/
readonly path: Promise<path.IPath>;
/**
* Converts the given path to a file URI in the remote environment.
*/
fileURI(path: string): Promise<URI>;
/**
* Resolves the user home of the remote environment if defined.
*/
readonly userHome: Promise<URI>;
/**
* Provides access to the user home of the remote environment
* if defined.
*/
readonly userHomeSync: URI | undefined;
}
/**
......@@ -30,12 +47,15 @@ export class RemotePathService implements IRemotePathService {
_serviceBrand: undefined;
private _extHostOS: Promise<platform.OperatingSystem>;
private _userHomeSync: URI | undefined;
constructor(
@IRemoteAgentService private readonly remoteAgentService: IRemoteAgentService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
) {
this._extHostOS = remoteAgentService.getEnvironment().then(remoteEnvironment => {
this._userHomeSync = remoteEnvironment?.userHome;
return remoteEnvironment ? remoteEnvironment.os : platform.OS;
});
}
......@@ -93,6 +113,10 @@ export class RemotePathService implements IRemotePathService {
return this.environmentService.userHome!;
});
}
get userHomeSync(): URI | undefined {
return this._userHomeSync || this.environmentService.userHome;
}
}
registerSingleton(IRemotePathService, RemotePathService, true);
......@@ -1110,6 +1110,7 @@ export class TestRemotePathService implements IRemotePathService {
get path() { return Promise.resolve(isWindows ? win32 : posix); }
get userHome() { return Promise.resolve(this.environmentService.userHome!); }
get userHomeSync() { return this.environmentService.userHome; }
async fileURI(path: string): Promise<URI> {
return URI.file(path);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册