Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fs-methods on IHostUtils optional and handle that accordingly #186709

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/vs/workbench/api/common/extHostExtensionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export interface IHostUtils {
readonly _serviceBrand: undefined;
readonly pid: number | undefined;
exit(code: number): void;
exists(path: string): Promise<boolean>;
realpath(path: string): Promise<string>;
fsExists?(path: string): Promise<boolean>;
fsRealpath?(path: string): Promise<string>;
}

type TelemetryActivationEventFragment = {
Expand Down Expand Up @@ -325,11 +325,11 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
* Applies realpath to file-uris and returns all others uris unmodified
*/
private async _realPathExtensionUri(uri: URI): Promise<URI> {
if (uri.scheme !== Schemas.file) {
return uri;
if (uri.scheme === Schemas.file && this._hostUtils.fsRealpath) {
const realpathValue = await this._hostUtils.fsRealpath(uri.fsPath);
return URI.file(realpathValue);
}
const realpathValue = await this._hostUtils.realpath(uri.fsPath);
return URI.file(realpathValue);
return uri;
}

// create trie to enable fast 'filename -> extension id' look up
Expand Down Expand Up @@ -683,8 +683,8 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
const host: IExtensionActivationHost = {
logService: this._logService,
folders: folders.map(folder => folder.uri),
forceUsingSearch: localWithRemote,
exists: (uri) => this._hostUtils.exists(uri.fsPath),
forceUsingSearch: localWithRemote || !this._hostUtils.fsExists,
exists: (uri) => this._hostUtils.fsExists!(uri.fsPath),
checkExists: (folders, includes, token) => this._mainThreadWorkspaceProxy.$checkExists(folders, includes, token)
};

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/node/extensionHostProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ async function startExtensionHostProcess(): Promise<void> {
declare readonly _serviceBrand: undefined;
public readonly pid = process.pid;
exit(code: number) { nativeExit(code); }
exists(path: string) { return Promises.exists(path); }
realpath(path: string) { return realpath(path); }
fsExists(path: string) { return Promises.exists(path); }
fsRealpath(path: string) { return realpath(path); }
};

// Attempt to load uri transformer
Expand Down
6 changes: 0 additions & 6 deletions src/vs/workbench/api/worker/extensionHostWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,6 @@ const hostUtil = new class implements IHostUtils {
exit(_code?: number | undefined): void {
nativeClose();
}
async exists(_path: string): Promise<boolean> {
return true;
}
async realpath(path: string): Promise<string> {
return path;
}
};


Expand Down