Skip to content

Commit

Permalink
Activate only if already active
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Grant <[email protected]>
  • Loading branch information
colin-grant-work committed Apr 13, 2021
1 parent 148e70c commit 302f87c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ before(() => {
// Mock out injected dependencies.
testContainer.bind(EditorManager).toDynamicValue(ctx => mockEditorManager);
testContainer.bind(WidgetManager).toDynamicValue(ctx => mockWidgetManager);
(<any>mockShell)['tracker'] = { activeWidget: undefined };
testContainer.bind(ApplicationShell).toConstantValue(mockShell);
testContainer.bind(PreferenceService).toDynamicValue(ctx => mockPreference);

Expand Down
8 changes: 5 additions & 3 deletions packages/editor-preview/src/browser/editor-preview-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,17 @@ export class EditorPreviewManager extends WidgetOpenHandler<EditorPreviewWidget
widget.disposed.connect(() => this.currentEditorPreview = Promise.resolve(undefined));

widget.onPinned(({ preview, editorWidget }) => {
// TODO(caseyflynn): I don't believe there is ever a case where
// this will not hold true.
const wasActive = this.shell.activeWidget === preview || this.shell.activeWidget === editorWidget;
// TODO(caseyflynn): I don't believe there is ever a case where the parent will not be a DockPanel.
if (preview.parent && preview.parent instanceof DockPanel) {
preview.parent.addWidget(editorWidget, { ref: preview });
} else {
this.shell.addWidget(editorWidget, { area: 'main' });
}
preview.dispose();
this.shell.activateWidget(editorWidget.id);
if (wasActive) {
this.shell.activateWidget(editorWidget.id);
}
this.currentEditorPreview = Promise.resolve(undefined);
});
}
Expand Down

0 comments on commit 302f87c

Please sign in to comment.