From 0ed7b0e701592f42374e825fb1a22cd41bf97305 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 15 Aug 2018 10:48:09 +0200 Subject: [PATCH] rename abbreviation to letter, #54938 --- extensions/git/src/decorationProvider.ts | 2 +- extensions/git/src/repository.ts | 4 ++-- src/vs/vscode.proposed.d.ts | 6 +++--- .../workbench/api/node/extHostDecorations.ts | 18 +++++++++++++----- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/extensions/git/src/decorationProvider.ts b/extensions/git/src/decorationProvider.ts index 48594918f5d92..4d15bb814ac79 100644 --- a/extensions/git/src/decorationProvider.ts +++ b/extensions/git/src/decorationProvider.ts @@ -93,7 +93,7 @@ class GitDecorationProvider implements DecorationProvider { private static SubmoduleDecorationData: DecorationData = { title: 'Submodule', - abbreviation: 'S', + letter: 'S', color: new ThemeColor('gitDecoration.submoduleResourceForeground') }; diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index b3af06983127e..c2c9a2f344d55 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -259,10 +259,10 @@ export class Resource implements SourceControlResourceState { get resourceDecoration(): DecorationData { const title = this.tooltip; - const abbreviation = this.letter; + const letter = this.letter; const color = this.color; const priority = this.priority; - return { bubble: true, source: 'git.resource', title, abbreviation, color, priority }; + return { bubble: true, source: 'git.resource', title, letter, color, priority }; } constructor( diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index ffb260b891fcd..e48ce71fb1a1f 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -357,11 +357,11 @@ declare module 'vscode' { //todo@joh -> make class export interface DecorationData { + letter: string; + title: string; + color?: ThemeColor; priority?: number; - title?: string; bubble?: boolean; - abbreviation?: string; // letter, not optional - color?: ThemeColor; source?: string; // hacky... we should remove it and use equality under the hood } diff --git a/src/vs/workbench/api/node/extHostDecorations.ts b/src/vs/workbench/api/node/extHostDecorations.ts index 763caf53ab9c4..4ffee73859666 100644 --- a/src/vs/workbench/api/node/extHostDecorations.ts +++ b/src/vs/workbench/api/node/extHostDecorations.ts @@ -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(); + private readonly _provider = new Map(); 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 && [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 && [data.priority, data.bubble, data.title, data.letter, data.color, data.source]; }, err => { console.error(err); });