Skip to content

Commit

Permalink
fix eclipse-theia#6979: ApplicationShell.getAreaFor should treat tab …
Browse files Browse the repository at this point in the history
…bars specially

since they are not shell widgets

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov authored and Sean Hellum committed Mar 12, 2020
1 parent 1b80dac commit 39fcb7d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
1 change: 1 addition & 0 deletions examples/api-tests/src/views.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('Views', function () {
assert.notEqual(view, undefined);
assert.equal(shell.getAreaFor(view), contribution.defaultViewOptions.area);
assert.isDefined(shell.getTabBarFor(view));
assert.equal(shell.getAreaFor(shell.getTabBarFor(view)), contribution.defaultViewOptions.area);
assert.isTrue(view.isVisible);
assert.equal(view, shell.activeWidget);

Expand Down
51 changes: 25 additions & 26 deletions packages/core/src/browser/shell/application-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1326,41 +1326,40 @@ export class ApplicationShell extends Widget {
* Determine the name of the shell area where the given widget resides. The result is
* undefined if the widget does not reside directly in the shell.
*/
getAreaFor(input: Widget): ApplicationShell.Area | undefined {
const widget = this.toTrackedStack(input.id).pop();
if (!widget) {
return undefined;
}
if (widget instanceof TabBar) {
if (find(this.mainPanel.tabBars(), tb => tb === widget)) {
return 'main';
}
if (find(this.bottomPanel.tabBars(), tb => tb === widget)) {
return 'bottom';
}
if (this.leftPanelHandler.tabBar === widget) {
return 'left';
}
if (this.rightPanelHandler.tabBar === widget) {
return 'right';
}
} else {
const title = widget.title;
const mainPanelTabBar = this.mainPanel.findTabBar(title);
if (mainPanelTabBar) {
getAreaFor(input: TabBar<Widget> | Widget): ApplicationShell.Area | undefined {
if (input instanceof TabBar) {
if (find(this.mainPanel.tabBars(), tb => tb === input)) {
return 'main';
}
const bottomPanelTabBar = this.bottomPanel.findTabBar(title);
if (bottomPanelTabBar) {
if (find(this.bottomPanel.tabBars(), tb => tb === input)) {
return 'bottom';
}
if (ArrayExt.firstIndexOf(this.leftPanelHandler.tabBar.titles, title) > -1) {
if (this.leftPanelHandler.tabBar === input) {
return 'left';
}
if (ArrayExt.firstIndexOf(this.rightPanelHandler.tabBar.titles, title) > -1) {
if (this.rightPanelHandler.tabBar === input) {
return 'right';
}
}
const widget = this.toTrackedStack(input.id).pop();
if (!widget) {
return undefined;
}
const title = widget.title;
const mainPanelTabBar = this.mainPanel.findTabBar(title);
if (mainPanelTabBar) {
return 'main';
}
const bottomPanelTabBar = this.bottomPanel.findTabBar(title);
if (bottomPanelTabBar) {
return 'bottom';
}
if (ArrayExt.firstIndexOf(this.leftPanelHandler.tabBar.titles, title) > -1) {
return 'left';
}
if (ArrayExt.firstIndexOf(this.rightPanelHandler.tabBar.titles, title) > -1) {
return 'right';
}
return undefined;
}

Expand Down

0 comments on commit 39fcb7d

Please sign in to comment.