Skip to content

Commit

Permalink
rename abbreviation to letter, #54938
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Aug 15, 2018
1 parent 5a25b69 commit 0ed7b0e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion extensions/git/src/decorationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class GitDecorationProvider implements DecorationProvider {

private static SubmoduleDecorationData: DecorationData = {
title: 'Submodule',
abbreviation: 'S',
letter: 'S',
color: new ThemeColor('gitDecoration.submoduleResourceForeground')
};

Expand Down
4 changes: 2 additions & 2 deletions extensions/git/src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
18 changes: 13 additions & 5 deletions src/vs/workbench/api/node/extHostDecorations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 => {
Expand All @@ -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);
});
Expand Down

0 comments on commit 0ed7b0e

Please sign in to comment.