Skip to content

Commit

Permalink
fixes to tree decorator listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
kenneth-marut-work committed Jul 9, 2021
1 parent b9406d7 commit 07d1412
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ export class EditorPreviewTreeDecorator implements TreeDecorator, FrontendApplic

protected registerEditorListeners(widget: Widget): void {
const saveable = Saveable.get(widget);
if (saveable && widget instanceof EditorPreviewWidget) {
if (saveable) {
this.toDisposeOnDirtyChanged.set(widget.id, saveable.onDirtyChanged(() => {
this.fireDidChangeDecorations((tree: Tree) => this.collectDecorators(tree));
}));
}
if (widget instanceof EditorPreviewWidget) {
this.toDisposeOnPreviewPinned.set(widget.id, widget.onDidChangePreviewState(() => {
this.fireDidChangeDecorations((tree: Tree) => this.collectDecorators(tree));
this.toDisposeOnPreviewPinned.get(widget.id)?.dispose();
Expand All @@ -79,10 +81,8 @@ export class EditorPreviewTreeDecorator implements TreeDecorator, FrontendApplic
protected unregisterEditorListeners(widget: Widget): void {
this.toDisposeOnDirtyChanged.get(widget.id)?.dispose();
this.toDisposeOnDirtyChanged.delete(widget.id);
if (widget instanceof EditorPreviewWidget && widget.isPreview) {
this.toDisposeOnPreviewPinned.get(widget.id)?.dispose();
this.toDisposeOnDirtyChanged.delete(widget.id);
}
this.toDisposeOnPreviewPinned.get(widget.id)?.dispose();
this.toDisposeOnPreviewPinned.delete(widget.id);
}

protected get editorWidgets(): NavigatableWidget[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ export class OpenEditorsModel extends FileTreeModel {

get editorWidgets(): NavigatableWidget[] {
const editorWidgets: NavigatableWidget[] = [];
this._editorWidgetsByArea.forEach(widgets => {
editorWidgets.push(...widgets);
});
this._editorWidgetsByArea.forEach(widgets => editorWidgets.push(...widgets));
return editorWidgets;
}

Expand Down Expand Up @@ -96,7 +94,6 @@ export class OpenEditorsModel extends FileTreeModel {
this.applicationShell.bottomPanel.layoutModified.connect(() => this.doUpdateOpenWidgets('bottom'));
}


protected async initializeRoot(): Promise<void> {
await this.updateOpenWidgets();
this.fireChanged();
Expand All @@ -108,7 +105,7 @@ export class OpenEditorsModel extends FileTreeModel {
this._lastEditorWidgetsByArea = this._editorWidgetsByArea;
this._editorWidgetsByArea = new Map<ApplicationShell.Area, NavigatableWidget[]>();
let doRebuild = true;
const areas: ApplicationShell.Area[] = ['main', 'bottom', 'left', 'right', 'bottom'];
const areas: ApplicationShell.Area[] = ['main', 'bottom', 'left', 'right', 'top'];
areas.forEach(area => {
const editorWidgetsForArea = this.applicationShell.getWidgets(area).filter((widget): widget is NavigatableWidget => NavigatableWidget.is(widget));
if (editorWidgetsForArea.length) {
Expand Down

0 comments on commit 07d1412

Please sign in to comment.