mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
make event optional, event naming, relax badge length a little, https://github.com/microsoft/vscode/issues/54938
This commit is contained in:
@@ -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
|
||||
@@ -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>();
|
||||
|
||||
Vendored
+2
-2
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
@@ -75,7 +75,7 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
|
||||
});
|
||||
|
||||
return new Disposable(() => {
|
||||
listener.dispose();
|
||||
listener?.dispose();
|
||||
this._proxy.$unregisterDecorationProvider(handle);
|
||||
this._provider.delete(handle);
|
||||
});
|
||||
|
||||
@@ -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`);
|
||||
|
||||
Reference in New Issue
Block a user