Skip to content

Commit

Permalink
make event optional, event naming, relax badge length a little, #54938
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken authored and meganrogge committed Nov 18, 2020
1 parent c0c2311 commit f90a026
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions extensions/git/src/decorationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class GitIgnoreDecorationProvider implements FileDecorationProvider {

private static Decoration: FileDecoration = { color: new ThemeColor('gitDecoration.ignoredResourceForeground') };

readonly onDidChange: Event<Uri[]>;
readonly onDidChangeFileDecorations: Event<Uri[]>;
private queue = new Map<string, { repository: Repository; queue: Map<string, PromiseSource<FileDecoration | undefined>>; }>();
private disposables: Disposable[] = [];

constructor(private model: Model) {
this.onDidChange = fireEvent(anyEvent<any>(
this.onDidChangeFileDecorations = fireEvent(anyEvent<any>(
filterEvent(workspace.onDidSaveTextDocument, e => /\.gitignore$|\.git\/info\/exclude$/.test(e.uri.path)),
model.onDidOpenRepository,
model.onDidCloseRepository
Expand Down Expand Up @@ -93,7 +93,7 @@ class GitDecorationProvider implements FileDecorationProvider {
};

private readonly _onDidChangeDecorations = new EventEmitter<Uri[]>();
readonly onDidChange: Event<Uri[]> = this._onDidChangeDecorations.event;
readonly onDidChangeFileDecorations: Event<Uri[]> = this._onDidChangeDecorations.event;

private disposables: Disposable[] = [];
private decorations = new Map<string, FileDecoration>();
Expand Down
4 changes: 2 additions & 2 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,9 @@ declare module 'vscode' {
/**
* An event to signal decorations for one or many files have changed.
*
* @see [EventEmitter](#EventEmitter
* @see [EventEmitter](#EventEmitter)
*/
onDidChange: Event<undefined | Uri | Uri[]>;
onDidChangeFileDecorations?: Event<undefined | Uri | Uri[]>;

/**
* Provide decorations for a given uri.
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/common/extHostDecorations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
this._provider.set(handle, { provider, extensionId });
this._proxy.$registerDecorationProvider(handle, extensionId.value);

const listener = provider.onDidChange(e => {
const listener = provider.onDidChangeFileDecorations && provider.onDidChangeFileDecorations(e => {
if (!e) {
this._proxy.$onDidChange(handle, null);
return;
Expand Down Expand Up @@ -75,7 +75,7 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
});

return new Disposable(() => {
listener.dispose();
listener?.dispose();
this._proxy.$unregisterDecorationProvider(handle);
this._provider.delete(handle);
});
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2720,8 +2720,8 @@ export enum ExtensionKind {
export class FileDecoration {

static validate(d: FileDecoration): void {
if (d.badge && d.badge.length !== 1) {
throw new Error(`The 'badge'-property must be undefined or a single character`);
if (d.badge && (d.badge.length === 1 || d.badge.length === 2)) {
throw new Error(`The 'badge'-property must be undefined or a short character`);
}
if (!d.color && !d.badge && !d.tooltip) {
throw new Error(`The decoration is empty`);
Expand Down

0 comments on commit f90a026

Please sign in to comment.