rename abbreviation to letter, #54938

This commit is contained in:
Johannes Rieken
2018-08-15 10:48:09 +02:00
parent 5a25b69ee5
commit 0ed7b0e701
4 changed files with 20 additions and 12 deletions

View File

@@ -11,11 +11,16 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { Disposable } from 'vs/workbench/api/node/extHostTypes';
import { asWinJsPromise } from 'vs/base/common/async';
interface ProviderData {
provider: vscode.DecorationProvider;
extensionId: string;
}
export class ExtHostDecorations implements ExtHostDecorationsShape {
private static _handlePool = 0;
private readonly _provider = new Map<number, vscode.DecorationProvider>();
private readonly _provider = new Map<number, ProviderData>();
private readonly _proxy: MainThreadDecorationsShape;
constructor(mainContext: IMainContext) {
@@ -24,7 +29,7 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
registerDecorationProvider(provider: vscode.DecorationProvider, extensionId: string): vscode.Disposable {
const handle = ExtHostDecorations._handlePool++;
this._provider.set(handle, provider);
this._provider.set(handle, { provider, extensionId });
this._proxy.$registerDecorationProvider(handle, extensionId);
const listener = provider.onDidChangeDecorations(e => {
@@ -42,13 +47,16 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
const result: DecorationReply = Object.create(null);
return TPromise.join(requests.map(request => {
const { handle, uri, id } = request;
const provider = this._provider.get(handle);
if (!provider) {
if (!this._provider.has(handle)) {
// might have been unregistered in the meantime
return void 0;
}
const { provider, extensionId } = this._provider.get(handle);
return asWinJsPromise(token => provider.provideDecoration(URI.revive(uri), token)).then(data => {
result[id] = data && <DecorationData>[data.priority, data.bubble, data.title, data.abbreviation, data.color, data.source];
if (!data.letter || data.letter.length !== 1) {
console.warn(`INVALID decoration from extension '${extensionId}'. The 'letter' must be set and be one character`);
}
result[id] = data && <DecorationData>[data.priority, data.bubble, data.title, data.letter, data.color, data.source];
}, err => {
console.error(err);
});