diff --git a/src/@types/vsls.d.ts b/src/@types/vsls.d.ts index 3060b75..310c3b7 100644 --- a/src/@types/vsls.d.ts +++ b/src/@types/vsls.d.ts @@ -74,7 +74,7 @@ export interface SharedServiceProxy { readonly onDidChangeIsServiceAvailable: Event; onNotify(name: string, handler: NotifyHandler): void; - request(name: string, args: any[], cancellation?: CancellationToken): Promise; + request(name: string, args: any[], cancellation?: CancellationToken): Promise; notify(name: string, args: object): void; } diff --git a/src/env/node/git/vslsGitProvider.ts b/src/env/node/git/vslsGitProvider.ts index 663a475..52ff6a3 100644 --- a/src/env/node/git/vslsGitProvider.ts +++ b/src/env/node/git/vslsGitProvider.ts @@ -64,7 +64,8 @@ export class VslsGitProvider extends LocalGitProvider { override canHandlePathOrUri(scheme: string, pathOrUri: string | Uri): string | undefined { // TODO@eamodio To support virtual repositories, we need to verify that the path is local here (by converting the shared path to a local path) - return super.canHandlePathOrUri(scheme, pathOrUri); + const path = super.canHandlePathOrUri(scheme, pathOrUri); + return path != null ? `${scheme}:${path}` : undefined; } override getAbsoluteUri(pathOrUri: string | Uri, base: string | Uri): Uri { diff --git a/src/vsls/guest.ts b/src/vsls/guest.ts index c07e4ef..93f744c 100644 --- a/src/vsls/guest.ts +++ b/src/vsls/guest.ts @@ -56,8 +56,12 @@ export class VslsGuestService implements Disposable { } @log() - async git(options: GitCommandOptions, ...args: any[]) { - const response = await this.sendRequest(GitCommandRequestType, { options: options, args: args }); + async git(options: GitCommandOptions, ...args: any[]): Promise { + const response = await this.sendRequest(GitCommandRequestType, { + __type: 'gitlens', + options: options, + args: args, + }); if (response.isBuffer) { return Buffer.from(response.data, 'binary') as TOut; @@ -68,6 +72,7 @@ export class VslsGuestService implements Disposable { @log() async getRepositoriesForUri(uri: Uri): Promise { const response = await this.sendRequest(GetRepositoriesForUriRequestType, { + __type: 'gitlens', folderUri: uri.toString(), }); @@ -77,10 +82,9 @@ export class VslsGuestService implements Disposable { @debug() private sendRequest( requestType: RequestType, - request: TRequest, - _cancellation?: CancellationToken, + request: TRequest & { __type: string }, + cancellation?: CancellationToken, ): Promise { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return this._service.request(requestType.name, [request]); + return this._service.request(requestType.name, [request], cancellation); } } diff --git a/src/vsls/host.ts b/src/vsls/host.ts index cb9b316..e1883ee 100644 --- a/src/vsls/host.ts +++ b/src/vsls/host.ts @@ -90,9 +90,17 @@ export class VslsHostService implements Disposable { requestType: RequestType, handler: (request: TRequest, cancellation: CancellationToken) => Promise, ) { - this._service.onRequest(requestType.name, (args: any[], cancellation: CancellationToken) => - handler(args[0], cancellation), - ); + // eslint-disable-next-line prefer-arrow-callback + this._service.onRequest(requestType.name, function (args: any[], cancellation: CancellationToken) { + let request; + for (const arg of args) { + if (typeof arg === 'object' && '__type' in arg) { + request = arg; + break; + } + } + return handler(request ?? args[0], cancellation); + }); } @log() diff --git a/src/vsls/vsls.ts b/src/vsls/vsls.ts index a325d29..c813645 100644 --- a/src/vsls/vsls.ts +++ b/src/vsls/vsls.ts @@ -119,7 +119,9 @@ export class VslsController implements Disposable { this.setReadonly(false); void setContext('gitlens:vsls', true); - this._ready = defer(); + if (!this._ready.pending) { + this._ready = defer(); + } break; } @@ -132,8 +134,9 @@ export class VslsController implements Disposable { const vslsExtension = extension.isActive ? extension.exports : await extension.activate(); return (await vslsExtension.getApi('1.0.4753')) ?? undefined; } - } catch { + } catch (ex) { debugger; + Logger.error(ex); } return undefined;