Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)

* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998

* fix pipelines

* fix strict-null-checks

* add missing files
This commit is contained in:
Anthony Dresser
2019-10-21 22:12:22 -07:00
committed by GitHub
parent 7c9be74970
commit 1e22f47304
913 changed files with 18898 additions and 16536 deletions

View File

@@ -14,6 +14,8 @@ import { IConstructorSignature0, IInstantiationService } from 'vs/platform/insta
import { trackFocus, Dimension } from 'vs/base/browser/dom';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { Disposable } from 'vs/base/common/lifecycle';
import { assertIsDefined } from 'vs/base/common/types';
import { find } from 'vs/base/common/arrays';
/**
* Composites are layed out in the sidebar and panel part of the workbench. At a time only one composite
@@ -35,10 +37,10 @@ export abstract class Composite extends Component implements IComposite {
private readonly _onDidChangeVisibility: Emitter<boolean> = this._register(new Emitter<boolean>());
readonly onDidChangeVisibility: Event<boolean> = this._onDidChangeVisibility.event;
private _onDidFocus!: Emitter<void>;
private _onDidFocus: Emitter<void> | undefined;
get onDidFocus(): Event<void> {
if (!this._onDidFocus) {
this.registerFocusTrackEvents();
this._onDidFocus = this.registerFocusTrackEvents().onDidFocus;
}
return this._onDidFocus.event;
@@ -50,28 +52,32 @@ export abstract class Composite extends Component implements IComposite {
}
}
private _onDidBlur!: Emitter<void>;
private _onDidBlur: Emitter<void> | undefined;
get onDidBlur(): Event<void> {
if (!this._onDidBlur) {
this.registerFocusTrackEvents();
this._onDidBlur = this.registerFocusTrackEvents().onDidBlur;
}
return this._onDidBlur.event;
}
private registerFocusTrackEvents(): void {
this._onDidFocus = this._register(new Emitter<void>());
this._onDidBlur = this._register(new Emitter<void>());
private registerFocusTrackEvents(): { onDidFocus: Emitter<void>, onDidBlur: Emitter<void> } {
const container = assertIsDefined(this.getContainer());
const focusTracker = this._register(trackFocus(container));
const focusTracker = this._register(trackFocus(this.getContainer()));
this._register(focusTracker.onDidFocus(() => this._onDidFocus.fire()));
this._register(focusTracker.onDidBlur(() => this._onDidBlur.fire()));
const onDidFocus = this._onDidFocus = this._register(new Emitter<void>());
this._register(focusTracker.onDidFocus(() => onDidFocus.fire()));
const onDidBlur = this._onDidBlur = this._register(new Emitter<void>());
this._register(focusTracker.onDidBlur(() => onDidBlur.fire()));
return { onDidFocus, onDidBlur };
}
protected actionRunner: IActionRunner | undefined;
private visible: boolean;
private parent!: HTMLElement;
private parent: HTMLElement | undefined;
constructor(
id: string,
@@ -112,7 +118,7 @@ export abstract class Composite extends Component implements IComposite {
/**
* Returns the container this composite is being build in.
*/
getContainer(): HTMLElement {
getContainer(): HTMLElement | undefined {
return this.parent;
}
@@ -253,7 +259,7 @@ export abstract class CompositeRegistry<T extends Composite> extends Disposable
private composites: CompositeDescriptor<T>[] = [];
protected registerComposite(descriptor: CompositeDescriptor<T>): void {
if (this.compositeById(descriptor.id) !== null) {
if (this.compositeById(descriptor.id)) {
return;
}
@@ -271,7 +277,7 @@ export abstract class CompositeRegistry<T extends Composite> extends Disposable
this._onDidDeregister.fire(descriptor);
}
getComposite(id: string): CompositeDescriptor<T> | null {
getComposite(id: string): CompositeDescriptor<T> | undefined {
return this.compositeById(id);
}
@@ -279,13 +285,7 @@ export abstract class CompositeRegistry<T extends Composite> extends Disposable
return this.composites.slice(0);
}
private compositeById(id: string): CompositeDescriptor<T> | null {
for (const composite of this.composites) {
if (composite.id === id) {
return composite;
}
}
return null;
private compositeById(id: string): CompositeDescriptor<T> | undefined {
return find(this.composites, composite => composite.id === id);
}
}