提交 0ed7b0e7 编写于 作者: J Johannes Rieken

rename abbreviation to letter, #54938

上级 5a25b69e
......@@ -93,7 +93,7 @@ class GitDecorationProvider implements DecorationProvider {
private static SubmoduleDecorationData: DecorationData = {
title: 'Submodule',
abbreviation: 'S',
letter: 'S',
color: new ThemeColor('gitDecoration.submoduleResourceForeground')
};
......
......@@ -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(
......
......@@ -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
}
......
......@@ -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);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册