send requests per provider so that a hanging provider doesn't block other providers, https://github.com/microsoft/vscode/issues/100524

This commit is contained in:
Johannes Rieken
2020-06-23 11:23:03 +02:00
parent de1250599c
commit 3fd09e62b5
4 changed files with 130 additions and 46 deletions

View File

@@ -1525,7 +1525,6 @@ export interface ExtHostDebugServiceShape {
export interface DecorationRequest {
readonly id: number;
readonly handle: number;
readonly uri: UriComponents;
}
@@ -1533,7 +1532,7 @@ export type DecorationData = [number, boolean, string, string, ThemeColor];
export type DecorationReply = { [id: number]: DecorationData; };
export interface ExtHostDecorationsShape {
$provideDecorations(requests: DecorationRequest[], token: CancellationToken): Promise<DecorationReply>;
$provideDecorations(handle: number, requests: DecorationRequest[], token: CancellationToken): Promise<DecorationReply>;
}
export interface ExtHostWindowShape {

View File

@@ -52,17 +52,20 @@ export class ExtHostDecorations implements IExtHostDecorations {
});
}
$provideDecorations(requests: DecorationRequest[], token: CancellationToken): Promise<DecorationReply> {
async $provideDecorations(handle: number, requests: DecorationRequest[], token: CancellationToken): Promise<DecorationReply> {
if (!this._provider.has(handle)) {
// might have been unregistered in the meantime
return Object.create(null);
}
const result: DecorationReply = Object.create(null);
return Promise.all(requests.map(request => {
const { handle, uri, id } = request;
const entry = this._provider.get(handle);
if (!entry) {
// might have been unregistered in the meantime
return undefined;
}
const { provider, extensionId } = entry;
return Promise.resolve(provider.provideDecoration(URI.revive(uri), token)).then(data => {
const { provider, extensionId } = this._provider.get(handle)!;
await Promise.all(requests.map(async request => {
try {
const { uri, id } = request;
const data = await Promise.resolve(provider.provideDecoration(URI.revive(uri), token));
if (!data) {
return;
}
@@ -72,13 +75,12 @@ export class ExtHostDecorations implements IExtHostDecorations {
} catch (e) {
this._logService.warn(`INVALID decoration from extension '${extensionId.value}': ${e}`);
}
}, err => {
} catch (err) {
this._logService.error(err);
});
}
}));
})).then(() => {
return result;
});
return result;
}
}