提交 1cc7dd40 编写于 作者: I isidor

setVisible do not lie to the world, you are not async

上级 3dd2b19b
......@@ -92,7 +92,7 @@ export class MainThreadOutputService extends Disposable implements MainThreadOut
public $close(channelId: string): Thenable<void> {
const panel = this._panelService.getActivePanel();
if (panel && panel.getId() === OUTPUT_PANEL_ID && channelId === this._outputService.getActiveChannel().id) {
return this._partService.setPanelHidden(true);
this._partService.setPanelHidden(true);
}
return undefined;
......
......@@ -28,8 +28,9 @@ export class ToggleSidebarVisibilityAction extends Action {
run(): Thenable<any> {
const hideSidebar = this.partService.isVisible(Parts.SIDEBAR_PART);
this.partService.setSideBarHidden(hideSidebar);
return this.partService.setSideBarHidden(hideSidebar);
return Promise.resolve(null);
}
}
......
......@@ -118,14 +118,11 @@ export abstract class Composite extends Component implements IComposite {
* is called more than once during workbench lifecycle depending on the user interaction.
* The composite will be on-DOM if visible is set to true and off-DOM otherwise.
*
* The returned promise is complete when the composite is visible. As such it is valid
* to do a long running operation from this call. Typically this operation should be
* fast though because setVisible might be called many times during a session.
* Typically this operation should be fast though because setVisible might be called many times during a session.
* If there is a long running opertaion it is fine to have it running in the background asyncly and return before.
*/
setVisible(visible: boolean): Promise<void> {
setVisible(visible: boolean): void {
this.visible = visible;
return Promise.resolve(null);
}
/**
......
......@@ -261,7 +261,6 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
let sidebarPosition = this.partService.getSideBarPosition();
let isSidebarVisible = this.partService.isVisible(Parts.SIDEBAR_PART);
let newSashWidth = (sidebarPosition === Position.LEFT) ? startSidebarWidth + e.currentX - startX : startSidebarWidth - e.currentX + startX;
let promise: Thenable<void> = Promise.resolve<void>(null);
// Sidebar visible
if (isSidebarVisible) {
......@@ -269,7 +268,7 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
// Automatically hide side bar when a certain threshold is met
if (newSashWidth + HIDE_SIDEBAR_WIDTH_THRESHOLD < this.partLayoutInfo.sidebar.minWidth) {
let dragCompensation = this.partLayoutInfo.sidebar.minWidth - HIDE_SIDEBAR_WIDTH_THRESHOLD;
promise = this.partService.setSideBarHidden(true);
this.partService.setSideBarHidden(true);
startX = (sidebarPosition === Position.LEFT) ? Math.max(this.activitybarWidth, e.currentX - dragCompensation) : Math.min(e.currentX + dragCompensation, this.workbenchSize.width - this.activitybarWidth);
this.sidebarWidth = startSidebarWidth; // when restoring sidebar, restore to the sidebar width we started from
}
......@@ -287,12 +286,12 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
(sidebarPosition === Position.RIGHT && startX - e.currentX >= this.partLayoutInfo.sidebar.minWidth)) {
startSidebarWidth = this.partLayoutInfo.sidebar.minWidth - (sidebarPosition === Position.LEFT ? e.currentX - startX : startX - e.currentX);
this.sidebarWidth = this.partLayoutInfo.sidebar.minWidth;
promise = this.partService.setSideBarHidden(false);
this.partService.setSideBarHidden(false);
}
}
if (doLayout) {
promise.then(() => this.layout({ source: Parts.SIDEBAR_PART }));
this.layout({ source: Parts.SIDEBAR_PART });
}
}));
......@@ -300,7 +299,6 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
let doLayout = false;
let isPanelVisible = this.partService.isVisible(Parts.PANEL_PART);
let newSashHeight = startPanelHeight - (e.currentY - startY);
let promise: Thenable<void> = Promise.resolve<void>(null);
// Panel visible
if (isPanelVisible) {
......@@ -308,7 +306,7 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
// Automatically hide panel when a certain threshold is met
if (newSashHeight + HIDE_PANEL_HEIGHT_THRESHOLD < this.partLayoutInfo.panel.minHeight) {
let dragCompensation = this.partLayoutInfo.panel.minHeight - HIDE_PANEL_HEIGHT_THRESHOLD;
promise = this.partService.setPanelHidden(true);
this.partService.setPanelHidden(true);
startY = Math.min(this.sidebarHeight - this.statusbarHeight - this.titlebarHeight, e.currentY + dragCompensation);
this.panelHeight = startPanelHeight; // when restoring panel, restore to the panel height we started from
}
......@@ -325,12 +323,12 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
if (startY - e.currentY >= this.partLayoutInfo.panel.minHeight) {
startPanelHeight = 0;
this.panelHeight = this.partLayoutInfo.panel.minHeight;
promise = this.partService.setPanelHidden(false);
this.partService.setPanelHidden(false);
}
}
if (doLayout) {
promise.then(() => this.layout({ source: Parts.PANEL_PART }));
this.layout({ source: Parts.PANEL_PART });
}
}));
......@@ -338,7 +336,6 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
let doLayout = false;
let isPanelVisible = this.partService.isVisible(Parts.PANEL_PART);
let newSashWidth = startPanelWidth - (e.currentX - startXTwo);
let promise: Thenable<void> = Promise.resolve<void>(null);
// Panel visible
if (isPanelVisible) {
......@@ -346,7 +343,7 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
// Automatically hide panel when a certain threshold is met
if (newSashWidth + HIDE_PANEL_WIDTH_THRESHOLD < this.partLayoutInfo.panel.minWidth) {
let dragCompensation = this.partLayoutInfo.panel.minWidth - HIDE_PANEL_WIDTH_THRESHOLD;
promise = this.partService.setPanelHidden(true);
this.partService.setPanelHidden(true);
startXTwo = Math.min(this.workbenchSize.width - this.activitybarWidth, e.currentX + dragCompensation);
this.panelWidth = startPanelWidth; // when restoring panel, restore to the panel height we started from
}
......@@ -363,12 +360,12 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
if (startXTwo - e.currentX >= this.partLayoutInfo.panel.minWidth) {
startPanelWidth = 0;
this.panelWidth = this.partLayoutInfo.panel.minWidth;
promise = this.partService.setPanelHidden(false);
this.partService.setPanelHidden(false);
}
}
if (doLayout) {
promise.then(() => this.layout({ source: Parts.PANEL_PART }));
this.layout({ source: Parts.PANEL_PART });
}
}));
......@@ -397,7 +394,8 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
this.sidebarWidth = Math.max(optimalWidth, DEFAULT_SIDEBAR_PART_WIDTH);
this.storageService.store(WorkbenchLayout.sashXOneWidthSettingsKey, this.sidebarWidth, StorageScope.GLOBAL);
this.partService.setSideBarHidden(false).then(() => this.layout());
this.partService.setSideBarHidden(false);
this.layout();
}));
this._register(this.sashXTwo.onDidReset(() => {
......
......@@ -77,10 +77,12 @@ export abstract class TogglePanelAction extends Action {
run(): Thenable<any> {
if (this.isPanelFocused()) {
return this.partService.setPanelHidden(true);
this.partService.setPanelHidden(true);
} else {
this.panelService.openPanel(this.panelId, true);
}
return this.panelService.openPanel(this.panelId, true);
return Promise.resolve(null);
}
private isPanelActive(): boolean {
......
......@@ -62,7 +62,8 @@ export class ViewletActivityAction extends ActivityAction {
// Hide sidebar if selected viewlet already visible
if (sideBarVisible && activeViewlet && activeViewlet.getId() === this.activity.id) {
this.logAction('hide');
return this.partService.setSideBarHidden(true);
this.partService.setSideBarHidden(true);
return Promise.resolve(null);
}
this.logAction('show');
......@@ -96,7 +97,8 @@ export class ToggleViewletAction extends Action {
// Hide sidebar if selected viewlet already visible
if (sideBarVisible && activeViewlet && activeViewlet.getId() === this._viewlet.id) {
return this.partService.setSideBarHidden(true);
this.partService.setSideBarHidden(true);
return Promise.resolve(null);
}
return this.viewletService.openViewlet(this._viewlet.id, true);
......
......@@ -35,7 +35,7 @@ export interface ICompositeBarOptions {
getContextMenuActions: () => Action[];
openComposite: (compositeId: string) => TPromise<any>;
getDefaultCompositeId: () => string;
hidePart: () => TPromise<any>;
hidePart: () => void;
}
export class CompositeBar extends Widget implements ICompositeBar {
......
......@@ -6,11 +6,9 @@
import 'vs/css!./media/compositepart';
import * as nls from 'vs/nls';
import { defaultGenerator } from 'vs/base/common/idGenerator';
import { TPromise } from 'vs/base/common/winjs.base';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import * as strings from 'vs/base/common/strings';
import { Emitter } from 'vs/base/common/event';
import * as types from 'vs/base/common/types';
import * as errors from 'vs/base/common/errors';
import { ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
import { IActionItem, ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
......@@ -96,7 +94,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
this.lastActiveCompositeId = storageService.get(activeCompositeSettingsKey, StorageScope.WORKSPACE, this.defaultCompositeId);
}
protected openComposite(id: string, focus?: boolean): TPromise<Composite> {
protected openComposite(id: string, focus?: boolean): Composite {
// Check if composite already visible and just focus in that case
if (this.activeComposite && this.activeComposite.getId() === id) {
if (focus) {
......@@ -104,66 +102,57 @@ export abstract class CompositePart<T extends Composite> extends Part {
}
// Fullfill promise with composite that is being opened
return Promise.resolve(this.activeComposite);
return this.activeComposite;
}
// Open
return this.doOpenComposite(id, focus);
}
private doOpenComposite(id: string, focus?: boolean): TPromise<Composite> {
private doOpenComposite(id: string, focus?: boolean): Composite {
// Use a generated token to avoid race conditions from long running promises
const currentCompositeOpenToken = defaultGenerator.nextId();
this.currentCompositeOpenToken = currentCompositeOpenToken;
// Hide current
let hidePromise: TPromise<Composite>;
if (this.activeComposite) {
hidePromise = this.hideActiveComposite();
} else {
hidePromise = Promise.resolve(null);
this.hideActiveComposite();
}
return hidePromise.then(() => {
// Update Title
this.updateTitle(id);
// Update Title
this.updateTitle(id);
// Create composite
const composite = this.createComposite(id, true);
// Create composite
const composite = this.createComposite(id, true);
// Check if another composite opened meanwhile and return in that case
if ((this.currentCompositeOpenToken !== currentCompositeOpenToken) || (this.activeComposite && this.activeComposite.getId() !== composite.getId())) {
return undefined;
}
// Check if another composite opened meanwhile and return in that case
if ((this.currentCompositeOpenToken !== currentCompositeOpenToken) || (this.activeComposite && this.activeComposite.getId() !== composite.getId())) {
return Promise.resolve(null);
// Check if composite already visible and just focus in that case
if (this.activeComposite && this.activeComposite.getId() === composite.getId()) {
if (focus) {
composite.focus();
}
// Check if composite already visible and just focus in that case
if (this.activeComposite && this.activeComposite.getId() === composite.getId()) {
if (focus) {
composite.focus();
}
this._onDidCompositeOpen.fire({ composite, focus });
return composite;
}
// Fullfill promise with composite that is being opened
return Promise.resolve(composite);
}
// Show Composite and Focus
this.showComposite(composite);
if (focus) {
composite.focus();
}
// Show Composite and Focus
return this.showComposite(composite).then(() => {
if (focus) {
composite.focus();
}
// Fullfill promise with composite that is being opened
return composite;
});
}).then(composite => {
if (composite) {
this._onDidCompositeOpen.fire({ composite, focus });
}
// Return with the composite that is being opened
if (composite) {
this._onDidCompositeOpen.fire({ composite, focus });
}
return composite;
});
return composite;
}
protected createComposite(id: string, isActive?: boolean): Composite {
......@@ -196,7 +185,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
throw new Error(strings.format('Unable to find composite with id {0}', id));
}
protected showComposite(composite: Composite): TPromise<void> {
protected showComposite(composite: Composite): void {
// Remember Composite
this.activeComposite = composite;
......@@ -287,18 +276,17 @@ export abstract class CompositePart<T extends Composite> extends Part {
});
// Indicate to composite that it is now visible
return composite.setVisible(true).then(() => {
composite.setVisible(true);
// Make sure that the user meanwhile did not open another composite or closed the part containing the composite
if (!this.activeComposite || composite.getId() !== this.activeComposite.getId()) {
return;
}
// Make sure that the user meanwhile did not open another composite or closed the part containing the composite
if (!this.activeComposite || composite.getId() !== this.activeComposite.getId()) {
return;
}
// Make sure the composite is layed out
if (this.contentAreaSize) {
composite.layout(this.contentAreaSize);
}
}, error => this.onError(error));
// Make sure the composite is layed out
if (this.contentAreaSize) {
composite.layout(this.contentAreaSize);
}
}
protected onTitleAreaUpdate(compositeId: string): void {
......@@ -360,9 +348,9 @@ export abstract class CompositePart<T extends Composite> extends Part {
return this.lastActiveCompositeId;
}
protected hideActiveComposite(): TPromise<Composite> {
protected hideActiveComposite(): Composite {
if (!this.activeComposite) {
return Promise.resolve(null); // Nothing to do
return undefined; // Nothing to do
}
const composite = this.activeComposite;
......@@ -371,21 +359,20 @@ export abstract class CompositePart<T extends Composite> extends Part {
const compositeContainer = this.mapCompositeToCompositeContainer[composite.getId()];
// Indicate to Composite
return composite.setVisible(false).then(() => {
composite.setVisible(false);
// Take Container Off-DOM and hide
compositeContainer.remove();
hide(compositeContainer);
// Take Container Off-DOM and hide
compositeContainer.remove();
hide(compositeContainer);
// Clear any running Progress
this.progressBar.stop().hide();
// Clear any running Progress
this.progressBar.stop().hide();
// Empty Actions
this.toolBar.setActions([])();
this._onDidCompositeClose.fire(composite);
// Empty Actions
this.toolBar.setActions([])();
this._onDidCompositeClose.fire(composite);
return composite;
});
return composite;
}
createTitleArea(parent: HTMLElement): HTMLElement {
......@@ -454,10 +441,6 @@ export abstract class CompositePart<T extends Composite> extends Part {
return contentContainer;
}
private onError(error: any): void {
this.notificationService.error(types.isString(error) ? new Error(error) : error);
}
getProgressIndicator(id: string): IProgressService {
return this.mapProgressServiceToComposite[id];
}
......
......@@ -897,8 +897,7 @@ export class MaximizeGroupAction extends Action {
run(): Thenable<any> {
if (this.editorService.activeEditor) {
this.editorGroupService.arrangeGroups(GroupsArrangement.MINIMIZE_OTHERS);
return this.partService.setSideBarHidden(true);
this.partService.setSideBarHidden(true);
}
return Promise.resolve(false);
......
......@@ -30,7 +30,8 @@ export class ClosePanelAction extends Action {
}
run(): Thenable<any> {
return this.partService.setPanelHidden(true);
this.partService.setPanelHidden(true);
return Promise.resolve(null);
}
}
......@@ -48,7 +49,8 @@ export class TogglePanelAction extends Action {
}
run(): Thenable<any> {
return this.partService.setPanelHidden(this.partService.isVisible(Parts.PANEL_PART));
this.partService.setPanelHidden(this.partService.isVisible(Parts.PANEL_PART));
return Promise.resolve(null);
}
}
......@@ -70,7 +72,8 @@ class FocusPanelAction extends Action {
// Show panel
if (!this.partService.isVisible(Parts.PANEL_PART)) {
return this.partService.setPanelHidden(false);
this.partService.setPanelHidden(false);
return Promise.resolve(null);
}
// Focus into active panel
......@@ -79,7 +82,7 @@ class FocusPanelAction extends Action {
panel.focus();
}
return Promise.resolve(true);
return Promise.resolve(null);
}
}
......@@ -116,7 +119,8 @@ export class TogglePanelPositionAction extends Action {
run(): Thenable<any> {
const position = this.partService.getPanelPosition();
return this.partService.setPanelPosition(position === Position.BOTTOM ? Position.RIGHT : Position.BOTTOM);
this.partService.setPanelPosition(position === Position.BOTTOM ? Position.RIGHT : Position.BOTTOM);
return Promise.resolve(null);
}
dispose(): void {
......@@ -153,9 +157,12 @@ export class ToggleMaximizedPanelAction extends Action {
}
run(): Thenable<any> {
const promise: Thenable<void> = !this.partService.isVisible(Parts.PANEL_PART) ? this.partService.setPanelHidden(false) : Promise.resolve(null);
if (!this.partService.isVisible(Parts.PANEL_PART)) {
this.partService.setPanelHidden(false);
}
return promise.then(() => this.partService.toggleMaximizedPanel());
this.partService.toggleMaximizedPanel();
return Promise.resolve(null);
}
dispose(): void {
......@@ -175,7 +182,9 @@ export class PanelActivityAction extends ActivityAction {
}
run(event: any): Thenable<any> {
return this.panelService.openPanel(this.activity.id, true).then(() => this.activate());
this.panelService.openPanel(this.activity.id, true);
this.activate();
return Promise.resolve(null);
}
}
......@@ -202,7 +211,8 @@ export class SwitchPanelViewAction extends Action {
break;
}
}
return this.panelService.openPanel(targetPanelId, true);
this.panelService.openPanel(targetPanelId, true);
return Promise.resolve(null);
}
}
......
......@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/panelpart';
import { TPromise } from 'vs/base/common/winjs.base';
import { IAction } from 'vs/base/common/actions';
import { Event, mapEvent } from 'vs/base/common/event';
import { Registry } from 'vs/platform/registry/common/platform';
......@@ -86,7 +85,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
icon: false,
storageId: PanelPart.PINNED_PANELS,
orientation: ActionsOrientation.HORIZONTAL,
openComposite: (compositeId: string) => this.openPanel(compositeId, true),
openComposite: (compositeId: string) => Promise.resolve(this.openPanel(compositeId, true)),
getActivityAction: (compositeId: string) => this.getCompositeActions(compositeId).activityAction,
getCompositePinnedAction: (compositeId: string) => this.getCompositeActions(compositeId).pinnedAction,
getOnCompositeClickAction: (compositeId: string) => this.instantiationService.createInstance(PanelActivityAction, this.getPanel(compositeId)),
......@@ -180,23 +179,22 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
title.style.borderTopColor = this.getColor(PANEL_BORDER) || this.getColor(contrastBorder);
}
openPanel(id: string, focus?: boolean): TPromise<Panel> {
openPanel(id: string, focus?: boolean): Panel {
if (this.blockOpeningPanel) {
return Promise.resolve(null); // Workaround against a potential race condition
return null; // Workaround against a potential race condition
}
// First check if panel is hidden and show if so
let promise = TPromise.wrap(null);
if (!this.partService.isVisible(Parts.PANEL_PART)) {
try {
this.blockOpeningPanel = true;
promise = this.partService.setPanelHidden(false);
this.partService.setPanelHidden(false);
} finally {
this.blockOpeningPanel = false;
}
}
return promise.then(() => this.openComposite(id, focus));
return this.openComposite(id, focus);
}
showActivity(panelId: string, badge: IBadge, clazz?: string): IDisposable {
......@@ -247,8 +245,8 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
return this.getLastActiveCompositetId();
}
hideActivePanel(): TPromise<void> {
return this.hideActiveComposite().then(composite => void 0);
hideActivePanel(): void {
this.hideActiveComposite();
}
protected createTitleLabel(parent: HTMLElement): ICompositeTitleLabel {
......
......@@ -124,23 +124,22 @@ export class SidebarPart extends CompositePart<Viewlet> {
container.style.borderLeftColor = !isPositionLeft ? borderColor : null;
}
openViewlet(id: string, focus?: boolean): TPromise<Viewlet> {
openViewlet(id: string, focus?: boolean): Viewlet {
if (this.blockOpeningViewlet) {
return Promise.resolve(null); // Workaround against a potential race condition
return null; // Workaround against a potential race condition
}
// First check if sidebar is hidden and show if so
let promise = TPromise.wrap<void>(null);
if (!this.partService.isVisible(Parts.SIDEBAR_PART)) {
try {
this.blockOpeningViewlet = true;
promise = this.partService.setSideBarHidden(false);
this.partService.setSideBarHidden(false);
} finally {
this.blockOpeningViewlet = false;
}
}
return promise.then(() => this.openComposite(id, focus)) as TPromise<Viewlet>;
return this.openComposite(id, focus) as Viewlet;
}
getActiveViewlet(): IViewlet {
......@@ -151,8 +150,8 @@ export class SidebarPart extends CompositePart<Viewlet> {
return this.getLastActiveCompositetId();
}
hideActiveViewlet(): TPromise<void> {
return this.hideActiveComposite().then(composite => void 0);
hideActiveViewlet(): void {
this.hideActiveComposite();
}
layout(dimension: Dimension): Dimension[] {
......@@ -198,7 +197,7 @@ class FocusSideBarAction extends Action {
// Show side bar
if (!this.partService.isVisible(Parts.SIDEBAR_PART)) {
return this.partService.setSideBarHidden(false);
return Promise.resolve(this.partService.setSideBarHidden(false));
}
// Focus into active viewlet
......
......@@ -59,8 +59,9 @@ export class CustomTreeViewPanel extends ViewletPanel {
this.updateTreeVisibility();
}
setVisible(visible: boolean): TPromise<void> {
return super.setVisible(visible).then(() => this.updateTreeVisibility());
setVisible(visible: boolean): void {
super.setVisible(visible);
this.updateTreeVisibility();
}
focus(): void {
......
......@@ -5,7 +5,6 @@
import 'vs/css!./media/panelviewlet';
import * as nls from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import { Event, Emitter, filterEvent } from 'vs/base/common/event';
import { ColorIdentifier } from 'vs/platform/theme/common/colorRegistry';
import { attachStyler, IColorMapping } from 'vs/platform/theme/common/styler';
......@@ -77,12 +76,10 @@ export abstract class ViewletPanel extends Panel implements IView {
this.actionRunner = options.actionRunner;
}
setVisible(visible: boolean): TPromise<void> {
setVisible(visible: boolean): void {
if (this._isVisible !== visible) {
this._isVisible = visible;
}
return TPromise.wrap(null);
}
isVisible(): boolean {
......
......@@ -42,12 +42,11 @@ export abstract class TreeViewsViewletPanel extends ViewletPanel {
}
}
setVisible(visible: boolean): TPromise<void> {
setVisible(visible: boolean): void {
if (this.isVisible() !== visible) {
return super.setVisible(visible)
.then(() => this.updateTreeVisibility(this.tree, visible && this.isExpanded()));
super.setVisible(visible);
this.updateTreeVisibility(this.tree, visible && this.isExpanded());
}
return TPromise.wrap(null);
}
focus(): void {
......@@ -189,11 +188,10 @@ export abstract class ViewContainerViewlet extends PanelViewlet implements IView
return result;
}
setVisible(visible: boolean): Promise<void> {
return super.setVisible(visible)
.then(() => Promise.all(this.panels.filter(view => view.isVisible() !== visible)
.map((view) => view.setVisible(visible))))
.then(() => void 0);
setVisible(visible: boolean): void {
super.setVisible(visible);
this.panels.filter(view => view.isVisible() !== visible)
.map((view) => view.setVisible(visible));
}
openView(id: string, focus?: boolean): TPromise<IView> {
......
......@@ -735,7 +735,7 @@ export abstract class BaseNavigationAction extends Action {
}
if (isSidebarFocus) {
return this.navigateOnSidebarFocus(isSidebarPositionLeft, isPanelPositionDown);
return Promise.resolve(this.navigateOnSidebarFocus(isSidebarPositionLeft, isPanelPositionDown));
}
return Promise.resolve(false);
......@@ -749,13 +749,13 @@ export abstract class BaseNavigationAction extends Action {
return Promise.resolve(true);
}
protected navigateOnSidebarFocus(_isSidebarPositionLeft: boolean, _isPanelPositionDown: boolean): Thenable<boolean | IViewlet> {
return Promise.resolve(true);
protected navigateOnSidebarFocus(_isSidebarPositionLeft: boolean, _isPanelPositionDown: boolean): boolean | IViewlet {
return true;
}
protected navigateToPanel(): Thenable<IPanel | boolean> {
protected navigateToPanel(): IPanel | boolean {
if (!this.partService.isVisible(Parts.PANEL_PART)) {
return Promise.resolve(false);
return false;
}
const activePanelId = this.panelService.getActivePanel().getId();
......@@ -773,23 +773,23 @@ export abstract class BaseNavigationAction extends Action {
return this.viewletService.openViewlet(activeViewletId, true);
}
protected navigateAcrossEditorGroup(direction: GroupDirection): Promise<boolean> {
protected navigateAcrossEditorGroup(direction: GroupDirection): boolean {
return this.doNavigateToEditorGroup({ direction });
}
protected navigateToEditorGroup(location: GroupLocation): Promise<boolean> {
protected navigateToEditorGroup(location: GroupLocation): boolean {
return this.doNavigateToEditorGroup({ location });
}
private doNavigateToEditorGroup(scope: IFindGroupScope): Promise<boolean> {
private doNavigateToEditorGroup(scope: IFindGroupScope): boolean {
const targetGroup = this.editorGroupService.findGroup(scope, this.editorGroupService.activeGroup);
if (targetGroup) {
targetGroup.focus();
return Promise.resolve(true);
return true;
}
return Promise.resolve(false);
return false;
}
}
......@@ -809,19 +809,17 @@ export class NavigateLeftAction extends BaseNavigationAction {
super(id, label, editorGroupService, panelService, partService, viewletService);
}
protected navigateOnEditorFocus(isSidebarPositionLeft: boolean, _isPanelPositionDown: boolean): Promise<boolean | IViewlet> {
return this.navigateAcrossEditorGroup(GroupDirection.LEFT)
.then(didNavigate => {
if (didNavigate) {
return Promise.resolve(true);
}
protected navigateOnEditorFocus(isSidebarPositionLeft: boolean, _isPanelPositionDown: boolean): Thenable<boolean | IViewlet> {
const didNavigate = this.navigateAcrossEditorGroup(GroupDirection.LEFT);
if (didNavigate) {
return Promise.resolve(true);
}
if (isSidebarPositionLeft) {
return this.navigateToSidebar();
}
if (isSidebarPositionLeft) {
return this.navigateToSidebar();
}
return Promise.resolve(false);
});
return Promise.resolve(false);
}
protected navigateOnPanelFocus(isSidebarPositionLeft: boolean, isPanelPositionDown: boolean): Thenable<boolean | IViewlet> {
......@@ -830,18 +828,18 @@ export class NavigateLeftAction extends BaseNavigationAction {
}
if (!isPanelPositionDown) {
return this.navigateToEditorGroup(GroupLocation.LAST);
return Promise.resolve(this.navigateToEditorGroup(GroupLocation.LAST));
}
return Promise.resolve(false);
}
protected navigateOnSidebarFocus(isSidebarPositionLeft: boolean, _isPanelPositionDown: boolean): Promise<boolean> {
protected navigateOnSidebarFocus(isSidebarPositionLeft: boolean, _isPanelPositionDown: boolean): boolean {
if (!isSidebarPositionLeft) {
return this.navigateToEditorGroup(GroupLocation.LAST);
}
return Promise.resolve(false);
return false;
}
}
......@@ -861,23 +859,21 @@ export class NavigateRightAction extends BaseNavigationAction {
super(id, label, editorGroupService, panelService, partService, viewletService);
}
protected navigateOnEditorFocus(isSidebarPositionLeft: boolean, isPanelPositionDown: boolean): Promise<boolean | IViewlet | IPanel> {
return this.navigateAcrossEditorGroup(GroupDirection.RIGHT)
.then(didNavigate => {
if (didNavigate) {
return Promise.resolve(true);
}
protected navigateOnEditorFocus(isSidebarPositionLeft: boolean, isPanelPositionDown: boolean): Thenable<boolean | IViewlet | IPanel> {
const didNavigate = this.navigateAcrossEditorGroup(GroupDirection.RIGHT);
if (didNavigate) {
return Promise.resolve(true);
}
if (!isPanelPositionDown) {
return this.navigateToPanel();
}
if (!isPanelPositionDown) {
return Promise.resolve(this.navigateToPanel());
}
if (!isSidebarPositionLeft) {
return this.navigateToSidebar();
}
if (!isSidebarPositionLeft) {
return this.navigateToSidebar();
}
return Promise.resolve(false);
});
return Promise.resolve(false);
}
protected navigateOnPanelFocus(isSidebarPositionLeft: boolean, _isPanelPositionDown: boolean): Thenable<boolean | IViewlet> {
......@@ -888,12 +884,12 @@ export class NavigateRightAction extends BaseNavigationAction {
return Promise.resolve(false);
}
protected navigateOnSidebarFocus(isSidebarPositionLeft: boolean, _isPanelPositionDown: boolean): Promise<boolean> {
protected navigateOnSidebarFocus(isSidebarPositionLeft: boolean, _isPanelPositionDown: boolean): boolean {
if (isSidebarPositionLeft) {
return this.navigateToEditorGroup(GroupLocation.FIRST);
}
return Promise.resolve(false);
return false;
}
}
......@@ -914,12 +910,12 @@ export class NavigateUpAction extends BaseNavigationAction {
}
protected navigateOnEditorFocus(_isSidebarPositionLeft: boolean, _isPanelPositionDown: boolean): Promise<boolean> {
return this.navigateAcrossEditorGroup(GroupDirection.UP);
return Promise.resolve(this.navigateAcrossEditorGroup(GroupDirection.UP));
}
protected navigateOnPanelFocus(_isSidebarPositionLeft: boolean, isPanelPositionDown: boolean): Promise<boolean> {
if (isPanelPositionDown) {
return this.navigateToEditorGroup(GroupLocation.LAST);
return Promise.resolve(this.navigateToEditorGroup(GroupLocation.LAST));
}
return Promise.resolve(false);
......@@ -943,18 +939,16 @@ export class NavigateDownAction extends BaseNavigationAction {
}
protected navigateOnEditorFocus(_isSidebarPositionLeft: boolean, isPanelPositionDown: boolean): Promise<boolean | IPanel> {
return this.navigateAcrossEditorGroup(GroupDirection.DOWN)
.then(didNavigate => {
if (didNavigate) {
return Promise.resolve(true);
}
const didNavigate = this.navigateAcrossEditorGroup(GroupDirection.DOWN);
if (didNavigate) {
return Promise.resolve(true);
}
if (isPanelPositionDown) {
return this.navigateToPanel();
}
if (isPanelPositionDown) {
return Promise.resolve(this.navigateToPanel());
}
return Promise.resolve(false);
});
return Promise.resolve(false);
}
}
......
......@@ -757,7 +757,8 @@ export class Workbench extends Disposable implements IPartService {
perf.mark('willRestorePanel');
const isPanelToRestoreEnabled = !!this.panelPart.getPanels().filter(p => p.id === panelId).length;
const panelIdToRestore = isPanelToRestoreEnabled ? panelId : panelRegistry.getDefaultPanelId();
restorePromises.push(this.panelPart.openPanel(panelIdToRestore, false).then(() => perf.mark('didRestorePanel')));
this.panelPart.openPanel(panelIdToRestore, false);
perf.mark('didRestorePanel');
}
// Restore Zen Mode if active
......@@ -1371,7 +1372,7 @@ export class Workbench extends Disposable implements IPartService {
}
}
setSideBarHidden(hidden: boolean, skipLayout?: boolean): TPromise<void> {
setSideBarHidden(hidden: boolean, skipLayout?: boolean): void {
this.sideBarHidden = hidden;
this.sideBarVisibleContext.set(!hidden);
......@@ -1383,47 +1384,45 @@ export class Workbench extends Disposable implements IPartService {
}
// If sidebar becomes hidden, also hide the current active Viewlet if any
let promise = TPromise.wrap<any>(null);
if (hidden && this.sidebarPart.getActiveViewlet()) {
promise = this.sidebarPart.hideActiveViewlet().then(() => {
const activePanel = this.panelPart.getActivePanel();
// Pass Focus to Editor or Panel if Sidebar is now hidden
if (this.hasFocus(Parts.PANEL_PART) && activePanel) {
activePanel.focus();
} else {
this.editorGroupService.activeGroup.focus();
}
});
this.sidebarPart.hideActiveViewlet();
const activePanel = this.panelPart.getActivePanel();
// Pass Focus to Editor or Panel if Sidebar is now hidden
if (this.hasFocus(Parts.PANEL_PART) && activePanel) {
activePanel.focus();
} else {
this.editorGroupService.activeGroup.focus();
}
}
// If sidebar becomes visible, show last active Viewlet or default viewlet
else if (!hidden && !this.sidebarPart.getActiveViewlet()) {
const viewletToOpen = this.sidebarPart.getLastActiveViewletId();
if (viewletToOpen) {
promise = this.viewletService.openViewlet(viewletToOpen, true)
.then(viewlet => viewlet || this.viewletService.openViewlet(this.viewletService.getDefaultViewletId(), true));
const viewlet = this.viewletService.openViewlet(viewletToOpen, true);
if (!viewlet) {
this.viewletService.openViewlet(this.viewletService.getDefaultViewletId(), true);
}
}
}
return promise.then(() => {
// Remember in settings
const defaultHidden = this.contextService.getWorkbenchState() === WorkbenchState.EMPTY;
if (hidden !== defaultHidden) {
this.storageService.store(Workbench.sidebarHiddenStorageKey, hidden ? 'true' : 'false', StorageScope.WORKSPACE);
} else {
this.storageService.remove(Workbench.sidebarHiddenStorageKey, StorageScope.WORKSPACE);
}
// Remember in settings
const defaultHidden = this.contextService.getWorkbenchState() === WorkbenchState.EMPTY;
if (hidden !== defaultHidden) {
this.storageService.store(Workbench.sidebarHiddenStorageKey, hidden ? 'true' : 'false', StorageScope.WORKSPACE);
} else {
this.storageService.remove(Workbench.sidebarHiddenStorageKey, StorageScope.WORKSPACE);
}
// Layout
if (!skipLayout) {
this.workbenchLayout.layout();
}
});
// Layout
if (!skipLayout) {
this.workbenchLayout.layout();
}
}
setPanelHidden(hidden: boolean, skipLayout?: boolean): TPromise<void> {
setPanelHidden(hidden: boolean, skipLayout?: boolean): void {
this.panelHidden = hidden;
// Adjust CSS
......@@ -1434,35 +1433,31 @@ export class Workbench extends Disposable implements IPartService {
}
// If panel part becomes hidden, also hide the current active panel if any
let promise = TPromise.wrap<any>(null);
if (hidden && this.panelPart.getActivePanel()) {
promise = this.panelPart.hideActivePanel().then(() => {
this.editorGroupService.activeGroup.focus(); // Pass focus to editor group if panel part is now hidden
});
this.panelPart.hideActivePanel();
this.editorGroupService.activeGroup.focus(); // Pass focus to editor group if panel part is now hidden
}
// If panel part becomes visible, show last active panel or default panel
else if (!hidden && !this.panelPart.getActivePanel()) {
const panelToOpen = this.panelPart.getLastActivePanelId();
if (panelToOpen) {
promise = this.panelPart.openPanel(panelToOpen, true);
this.panelPart.openPanel(panelToOpen, true);
}
}
return promise.then(() => {
// Remember in settings
if (!hidden) {
this.storageService.store(Workbench.panelHiddenStorageKey, 'false', StorageScope.WORKSPACE);
} else {
this.storageService.remove(Workbench.panelHiddenStorageKey, StorageScope.WORKSPACE);
}
// Remember in settings
if (!hidden) {
this.storageService.store(Workbench.panelHiddenStorageKey, 'false', StorageScope.WORKSPACE);
} else {
this.storageService.remove(Workbench.panelHiddenStorageKey, StorageScope.WORKSPACE);
}
// Layout
if (!skipLayout) {
this.workbenchLayout.layout();
}
});
// Layout
if (!skipLayout) {
this.workbenchLayout.layout();
}
}
toggleMaximizedPanel(): void {
......@@ -1518,23 +1513,25 @@ export class Workbench extends Disposable implements IPartService {
return this.panelPosition;
}
setPanelPosition(position: Position): TPromise<void> {
return (this.panelHidden ? this.setPanelHidden(false, true /* Skip Layout */) : TPromise.as(undefined)).then(() => {
const newPositionValue = (position === Position.BOTTOM) ? 'bottom' : 'right';
const oldPositionValue = (this.panelPosition === Position.BOTTOM) ? 'bottom' : 'right';
this.panelPosition = position;
this.storageService.store(Workbench.panelPositionStorageKey, PositionToString(this.panelPosition).toLowerCase(), StorageScope.WORKSPACE);
setPanelPosition(position: Position): void {
if (this.panelHidden) {
this.setPanelHidden(false, true /* Skip Layout */);
}
// Adjust CSS
DOM.removeClass(this.panelPart.getContainer(), oldPositionValue);
DOM.addClass(this.panelPart.getContainer(), newPositionValue);
const newPositionValue = (position === Position.BOTTOM) ? 'bottom' : 'right';
const oldPositionValue = (this.panelPosition === Position.BOTTOM) ? 'bottom' : 'right';
this.panelPosition = position;
this.storageService.store(Workbench.panelPositionStorageKey, PositionToString(this.panelPosition).toLowerCase(), StorageScope.WORKSPACE);
// Update Styles
this.panelPart.updateStyles();
// Adjust CSS
DOM.removeClass(this.panelPart.getContainer(), oldPositionValue);
DOM.addClass(this.panelPart.getContainer(), newPositionValue);
// Layout
this.workbenchLayout.layout();
});
// Update Styles
this.panelPart.updateStyles();
// Layout
this.workbenchLayout.layout();
}
//#endregion
......
......@@ -192,12 +192,11 @@ export class BreakpointsView extends ViewletPanel {
}
}
public setVisible(visible: boolean): TPromise<void> {
return super.setVisible(visible).then(() => {
if (visible && this.needsRefresh) {
this.onBreakpointsChange();
}
});
public setVisible(visible: boolean): void {
super.setVisible(visible);
if (visible && this.needsRefresh) {
this.onBreakpointsChange();
}
}
private onBreakpointsChange(): void {
......
......@@ -717,7 +717,8 @@ export class FocusReplAction extends Action {
}
public run(): TPromise<any> {
return this.panelService.openPanel(REPL_ID, true);
this.panelService.openPanel(REPL_ID, true);
return Promise.resolve(null);
}
}
......
......@@ -217,12 +217,11 @@ export class CallStackView extends TreeViewsViewletPanel {
});
}
public setVisible(visible: boolean): TPromise<void> {
return super.setVisible(visible).then(() => {
if (visible && this.needsRefresh) {
this.onCallStackChangeScheduler.schedule();
}
});
public setVisible(visible: boolean): void {
super.setVisible(visible);
if (visible && this.needsRefresh) {
this.onCallStackChangeScheduler.schedule();
}
}
}
......
......@@ -681,7 +681,8 @@ export class DebugService implements IDebugService {
: nls.localize('preLaunchTaskExitCode', "The preLaunchTask '{0}' terminated with exit code {1}.", taskLabel, taskSummary.exitCode);
const showErrorsAction = new Action('debug.showErrors', nls.localize('showErrors', "Show Errors"), undefined, true, () => {
return this.panelService.openPanel(Constants.MARKERS_PANEL_ID).then(() => TaskRunResult.Failure);
this.panelService.openPanel(Constants.MARKERS_PANEL_ID);
return Promise.resolve(TaskRunResult.Failure);
});
return this.showError(message, [debugAnywayAction, showErrorsAction]);
......
......@@ -139,12 +139,11 @@ export class VariablesView extends TreeViewsViewletPanel {
}
}
public setVisible(visible: boolean): TPromise<void> {
return super.setVisible(visible).then(() => {
if (visible && this.needsRefresh) {
this.onFocusStackFrameScheduler.schedule();
}
});
public setVisible(visible: boolean): void {
super.setVisible(visible);
if (visible && this.needsRefresh) {
this.onFocusStackFrameScheduler.schedule();
}
}
}
......
......@@ -122,12 +122,11 @@ export class WatchExpressionsView extends TreeViewsViewletPanel {
}
}
public setVisible(visible: boolean): TPromise<void> {
return super.setVisible(visible).then(() => {
if (visible && this.needsRefresh) {
this.onWatchExpressionsUpdatedScheduler.schedule();
}
});
public setVisible(visible: boolean): void {
super.setVisible(visible);
if (visible && this.needsRefresh) {
this.onWatchExpressionsUpdatedScheduler.schedule();
}
}
}
......
......@@ -361,15 +361,14 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio
super.create(this.extensionsBox);
}
setVisible(visible: boolean): Promise<void> {
setVisible(visible: boolean): void {
const isVisibilityChanged = this.isVisible() !== visible;
return super.setVisible(visible).then(() => {
if (isVisibilityChanged) {
if (visible) {
this.searchBox.focus();
}
super.setVisible(visible);
if (isVisibilityChanged) {
if (visible) {
this.searchBox.focus();
}
});
}
}
focus(): void {
......
......@@ -234,9 +234,9 @@ export class ExplorerViewlet extends ViewContainerViewlet implements IExplorerVi
return <EmptyView>this.getView(EmptyView.ID);
}
public setVisible(visible: boolean): Promise<void> {
public setVisible(visible: boolean): void {
this.viewletVisibleContextKey.set(visible);
return super.setVisible(visible);
super.setVisible(visible);
}
public getActionRunner(): IActionRunner {
......
......@@ -322,57 +322,54 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
}
}
public setVisible(visible: boolean): TPromise<void> {
return super.setVisible(visible).then(() => {
public setVisible(visible: boolean): void {
super.setVisible(visible);
// Show
if (visible) {
// Show
if (visible) {
// If a refresh was requested and we are now visible, run it
let refreshPromise: Thenable<void> = TPromise.as(null);
if (this.shouldRefresh) {
refreshPromise = this.doRefresh();
this.shouldRefresh = false; // Reset flag
}
if (!this.autoReveal) {
return refreshPromise; // do not react to setVisible call if autoReveal === false
}
// Always select the current navigated file in explorer if input is file editor input
// unless autoReveal is set to false
const activeFile = this.getActiveFile();
if (activeFile) {
return refreshPromise.then(() => {
return this.select(activeFile);
});
}
// If a refresh was requested and we are now visible, run it
let refreshPromise: Thenable<void> = TPromise.as(null);
if (this.shouldRefresh) {
refreshPromise = this.doRefresh();
this.shouldRefresh = false; // Reset flag
}
// Return now if the workbench has not yet been created - in this case the workbench takes care of restoring last used editors
if (!this.partService.isCreated()) {
return Promise.resolve(null);
}
if (!this.autoReveal) {
return; // do not react to setVisible call if autoReveal === false
}
// Otherwise restore last used file: By lastActiveFileResource
let lastActiveFileResource: URI;
if (this.viewState[ExplorerView.MEMENTO_LAST_ACTIVE_FILE_RESOURCE]) {
lastActiveFileResource = URI.parse(this.viewState[ExplorerView.MEMENTO_LAST_ACTIVE_FILE_RESOURCE]);
}
// Always select the current navigated file in explorer if input is file editor input
// unless autoReveal is set to false
const activeFile = this.getActiveFile();
if (activeFile) {
refreshPromise.then(() => {
this.select(activeFile);
});
return;
}
if (lastActiveFileResource && this.isCreated && this.model.findClosest(lastActiveFileResource)) {
this.editorService.openEditor({ resource: lastActiveFileResource, options: { revealIfVisible: true } });
// Return now if the workbench has not yet been created - in this case the workbench takes care of restoring last used editors
if (!this.partService.isCreated()) {
return;
}
return refreshPromise;
}
// Otherwise restore last used file: By lastActiveFileResource
let lastActiveFileResource: URI;
if (this.viewState[ExplorerView.MEMENTO_LAST_ACTIVE_FILE_RESOURCE]) {
lastActiveFileResource = URI.parse(this.viewState[ExplorerView.MEMENTO_LAST_ACTIVE_FILE_RESOURCE]);
}
// Otherwise restore last used file: By Explorer selection
return refreshPromise.then(() => {
this.openFocusedElement();
});
if (lastActiveFileResource && this.isCreated && this.model.findClosest(lastActiveFileResource)) {
this.editorService.openEditor({ resource: lastActiveFileResource, options: { revealIfVisible: true } });
return;
}
return void 0;
});
// Otherwise restore last used file: By Explorer selection
refreshPromise.then(() => {
this.openFocusedElement();
});
}
}
private openFocusedElement(preserveFocus?: boolean): void {
......
......@@ -297,13 +297,12 @@ export class OpenEditorsView extends ViewletPanel {
}
}
public setVisible(visible: boolean): TPromise<void> {
return super.setVisible(visible).then(() => {
this.updateListVisibility(visible && this.isExpanded());
if (visible && this.needsRefresh) {
this.listRefreshScheduler.schedule(0);
}
});
public setVisible(visible: boolean): void {
super.setVisible(visible);
this.updateListVisibility(visible && this.isExpanded());
if (visible && this.needsRefresh) {
this.listRefreshScheduler.schedule(0);
}
}
public focus(): void {
......
......@@ -70,7 +70,8 @@ export class ShowProblemsPanelAction extends Action {
}
public run(): TPromise<any> {
return this.panelService.openPanel(Constants.MARKERS_PANEL_ID, true);
this.panelService.openPanel(Constants.MARKERS_PANEL_ID, true);
return Promise.resolve(null);
}
}
......@@ -415,4 +416,4 @@ export class QuickFixActionItem extends ActionItem {
});
}
}
\ No newline at end of file
}
......@@ -21,7 +21,6 @@ import { dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { LRUCache } from 'vs/base/common/map';
import { escape } from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { ITree } from 'vs/base/parts/tree/browser/tree';
import 'vs/css!./outlinePanel';
import { ICodeEditor, isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser';
......@@ -383,12 +382,12 @@ export class OutlinePanel extends ViewletPanel {
}
}
setVisible(visible: boolean): TPromise<void> {
setVisible(visible: boolean): void {
if (visible && this.isExpanded() && !this._requestOracle) {
// workaround for https://github.com/Microsoft/vscode/issues/60011
this.setExpanded(true);
}
return super.setVisible(visible);
super.setVisible(visible);
}
setExpanded(expanded: boolean): void {
......
......@@ -494,10 +494,10 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
this.activeChannel = channel;
let promise: TPromise<void> = TPromise.as(null);
if (this.isPanelShown()) {
this.doShowChannel(channel, preserveFocus);
promise = this.doShowChannel(channel, preserveFocus);
} else {
promise = this.panelService.openPanel(OUTPUT_PANEL_ID)
.then(() => this.doShowChannel(this.activeChannel, preserveFocus));
this.panelService.openPanel(OUTPUT_PANEL_ID);
promise = this.doShowChannel(this.activeChannel, preserveFocus);
}
return promise.then(() => this._onActiveOutputChannel.fire(id));
}
......
......@@ -1184,9 +1184,8 @@ export class SCMViewlet extends PanelViewlet implements IViewModel, IViewsViewle
return (this.mainPanel ? 1 : 0) + this.repositoryPanels.length;
}
setVisible(visible: boolean): Promise<void> {
const promises: TPromise<any>[] = [];
promises.push(super.setVisible(visible));
setVisible(visible: boolean): void {
super.setVisible(visible);
if (!visible) {
this.cachedMainPanelHeight = this.getPanelSize(this.mainPanel);
......@@ -1198,10 +1197,8 @@ export class SCMViewlet extends PanelViewlet implements IViewModel, IViewsViewle
for (let i = 0; i < this.contributedViews.visibleViewDescriptors.length; i++) {
const panel = this.panels[start + i] as ViewletPanel;
promises.push(panel.setVisible(visible));
panel.setVisible(visible);
}
return Promise.all(promises).then(() => null);
}
getOptimalWidth(): number {
......
......@@ -50,7 +50,7 @@ export function openSearchView(viewletService: IViewletService, panelService: IP
return viewletService.openViewlet(VIEW_ID, focus).then(viewlet => <SearchView>viewlet);
}
return panelService.openPanel(VIEW_ID, focus).then(panel => <SearchView>panel);
return Promise.resolve(panelService.openPanel(VIEW_ID, focus) as SearchView);
}
export function getSearchView(viewletService: IViewletService, panelService: IPanelService): SearchView {
......
......@@ -651,8 +651,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
}
}
public setVisible(visible: boolean): Promise<void> {
let promise: Promise<void>;
public setVisible(visible: boolean): void {
this.viewletVisible.set(visible);
if (visible) {
if (this.changedWhileHidden) {
......@@ -661,11 +660,11 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.changedWhileHidden = false;
}
promise = super.setVisible(visible);
super.setVisible(visible);
this.tree.onVisible();
} else {
this.tree.onHidden();
promise = super.setVisible(visible);
super.setVisible(visible);
}
// Enable highlights if there are searchresults
......@@ -680,8 +679,6 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.onFocus(focus, true);
}
}
return promise;
}
public moveFocusToResults(): void {
......
......@@ -298,22 +298,21 @@ export abstract class TerminalService implements ITerminalService {
return new Promise<void>((complete) => {
const panel = this._panelService.getActivePanel();
if (!panel || panel.getId() !== TERMINAL_PANEL_ID) {
return this._panelService.openPanel(TERMINAL_PANEL_ID, focus).then(() => {
if (focus) {
// Do the focus call asynchronously as going through the
// command palette will force editor focus
setTimeout(() => {
const instance = this.getActiveInstance();
if (instance) {
instance.focusWhenReady(true).then(() => complete(void 0));
} else {
complete(void 0);
}
}, 0);
} else {
complete(void 0);
}
});
this._panelService.openPanel(TERMINAL_PANEL_ID, focus);
if (focus) {
// Do the focus call asynchronously as going through the
// command palette will force editor focus
setTimeout(() => {
const instance = this.getActiveInstance();
if (instance) {
instance.focusWhenReady(true).then(() => complete(void 0));
} else {
complete(void 0);
}
}, 0);
} else {
complete(void 0);
}
} else {
if (focus) {
// Do the focus call asynchronously as going through the
......
......@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import { Event } from 'vs/base/common/event';
import { TPromise } from 'vs/base/common/winjs.base';
import { IPanel } from 'vs/workbench/common/panel';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
......@@ -26,7 +25,7 @@ export interface IPanelService {
/**
* Opens a panel with the given identifier and pass keyboard focus to it if specified.
*/
openPanel(id: string, focus?: boolean): TPromise<IPanel>;
openPanel(id: string, focus?: boolean): IPanel;
/**
* Returns the current active panel or null if none
......
......@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { TPromise } from 'vs/base/common/winjs.base';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { Event } from 'vs/base/common/event';
import { MenuBarVisibility } from 'vs/platform/windows/common/windows';
......@@ -89,12 +88,12 @@ export interface IPartService {
/**
* Set sidebar hidden or not
*/
setSideBarHidden(hidden: boolean): TPromise<void>;
setSideBarHidden(hidden: boolean): void;
/**
* Set panel part hidden or not
*/
setPanelHidden(hidden: boolean): TPromise<void>;
setPanelHidden(hidden: boolean): void;
/**
* Maximizes the panel height if the panel is not already maximized.
......@@ -125,7 +124,7 @@ export interface IPartService {
/**
* Sets the panel position.
*/
setPanelPosition(position: Position): TPromise<void>;
setPanelPosition(position: Position): void;
/**
* Returns the element that contains the workbench.
......
......@@ -69,8 +69,8 @@ class TestPanelService implements IPanelService {
onDidPanelOpen = new Emitter<{ panel: IPanel, focus: boolean }>().event;
onDidPanelClose = new Emitter<IPanel>().event;
public openPanel(id: string, focus?: boolean): TPromise {
return TPromise.as(null);
public openPanel(id: string, focus?: boolean): IPanel {
return null;
}
public getPanels(): any[] {
......
......@@ -70,7 +70,7 @@ export class ViewletService extends Disposable implements IViewletService {
openViewlet(id: string, focus?: boolean): Thenable<IViewlet> {
if (this.getViewlet(id)) {
return this.sidebarPart.openViewlet(id, focus);
return Promise.resolve(this.sidebarPart.openViewlet(id, focus));
}
return this.extensionService.whenInstalledExtensionsRegistered()
.then(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册