mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
@@ -30,9 +30,7 @@ export class ToggleSidebarVisibilityAction extends Action {
|
||||
|
||||
public run(): TPromise<any> {
|
||||
const hideSidebar = this.partService.isVisible(Parts.SIDEBAR_PART);
|
||||
this.partService.setSideBarHidden(hideSidebar);
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.partService.setSideBarHidden(hideSidebar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
'use strict';
|
||||
|
||||
import { Dimension, Builder } from 'vs/base/browser/builder';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import { Part } from 'vs/workbench/browser/part';
|
||||
import { QuickOpenController } from 'vs/workbench/browser/parts/quickopen/quickOpenController';
|
||||
import { Sash, ISashEvent, IVerticalSashLayoutProvider, IHorizontalSashLayoutProvider, Orientation } from 'vs/base/browser/ui/sash/sash';
|
||||
@@ -144,6 +146,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
|
||||
let sidebarPosition = this.partService.getSideBarPosition();
|
||||
let isSidebarVisible = this.partService.isVisible(Parts.SIDEBAR_PART);
|
||||
let newSashWidth = (sidebarPosition === Position.LEFT) ? this.startSidebarWidth + e.currentX - startX : this.startSidebarWidth - e.currentX + startX;
|
||||
let promise = TPromise.as(null);
|
||||
|
||||
// Sidebar visible
|
||||
if (isSidebarVisible) {
|
||||
@@ -151,7 +154,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
|
||||
// Automatically hide side bar when a certain threshold is met
|
||||
if (newSashWidth + HIDE_SIDEBAR_WIDTH_THRESHOLD < this.computedStyles.sidebar.minWidth) {
|
||||
let dragCompensation = DEFAULT_MIN_SIDEBAR_PART_WIDTH - HIDE_SIDEBAR_WIDTH_THRESHOLD;
|
||||
this.partService.setSideBarHidden(true);
|
||||
promise = 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 = this.startSidebarWidth; // when restoring sidebar, restore to the sidebar width we started from
|
||||
}
|
||||
@@ -169,12 +172,12 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
|
||||
(sidebarPosition === Position.RIGHT && startX - e.currentX >= this.computedStyles.sidebar.minWidth)) {
|
||||
this.startSidebarWidth = this.computedStyles.sidebar.minWidth - (sidebarPosition === Position.LEFT ? e.currentX - startX : startX - e.currentX);
|
||||
this.sidebarWidth = this.computedStyles.sidebar.minWidth;
|
||||
this.partService.setSideBarHidden(false);
|
||||
promise = this.partService.setSideBarHidden(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (doLayout) {
|
||||
this.layout();
|
||||
promise.done(() => this.layout(), errors.onUnexpectedError);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -235,8 +238,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
|
||||
let optimalWidth = activeViewlet && activeViewlet.getOptimalWidth();
|
||||
this.sidebarWidth = Math.max(DEFAULT_MIN_SIDEBAR_PART_WIDTH, optimalWidth || 0);
|
||||
this.storageService.store(WorkbenchLayout.sashXWidthSettingsKey, this.sidebarWidth, StorageScope.GLOBAL);
|
||||
this.partService.setSideBarHidden(false);
|
||||
this.layout();
|
||||
this.partService.setSideBarHidden(false).done(() => this.layout(), errors.onUnexpectedError);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
import 'vs/css!./media/activityaction';
|
||||
import nls = require('vs/nls');
|
||||
import DOM = require('vs/base/browser/dom');
|
||||
import errors = require('vs/base/common/errors');
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Builder, $ } from 'vs/base/browser/builder';
|
||||
import { DelayedDragHandler } from 'vs/base/browser/dnd';
|
||||
@@ -93,13 +92,11 @@ export class ViewletActivityAction extends ActivityAction {
|
||||
|
||||
// Hide sidebar if selected viewlet already visible
|
||||
if (sideBarVisible && activeViewlet && activeViewlet.getId() === this.viewlet.id) {
|
||||
this.partService.setSideBarHidden(true);
|
||||
} else {
|
||||
this.viewletService.openViewlet(this.viewlet.id, true).done(null, errors.onUnexpectedError);
|
||||
this.activate();
|
||||
return this.partService.setSideBarHidden(true);
|
||||
}
|
||||
|
||||
return TPromise.as(true);
|
||||
return this.viewletService.openViewlet(this.viewlet.id, true)
|
||||
.then(() => this.activate());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,12 +528,10 @@ class OpenViewletAction extends Action {
|
||||
|
||||
// Hide sidebar if selected viewlet already visible
|
||||
if (sideBarVisible && activeViewlet && activeViewlet.getId() === this.viewlet.id) {
|
||||
this.partService.setSideBarHidden(true);
|
||||
} else {
|
||||
this.viewletService.openViewlet(this.viewlet.id, true).done(null, errors.onUnexpectedError);
|
||||
return this.partService.setSideBarHidden(true);
|
||||
}
|
||||
|
||||
return TPromise.as(true);
|
||||
return this.viewletService.openViewlet(this.viewlet.id, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
||||
// Case: we closed the last visible viewlet
|
||||
// Solv: we hide the sidebar
|
||||
else if (visibleViewlets.length === 1) {
|
||||
unpinPromise = TPromise.as(this.partService.setSideBarHidden(true));
|
||||
unpinPromise = this.partService.setSideBarHidden(true);
|
||||
}
|
||||
|
||||
// Case: we closed the default viewlet
|
||||
|
||||
@@ -824,7 +824,7 @@ export class MaximizeGroupAction extends Action {
|
||||
public run(): TPromise<any> {
|
||||
if (this.editorService.getActiveEditor()) {
|
||||
this.editorGroupService.arrangeGroups(GroupArrangement.MINIMIZE_OTHERS);
|
||||
this.partService.setSideBarHidden(true);
|
||||
return this.partService.setSideBarHidden(true);
|
||||
}
|
||||
|
||||
return TPromise.as(false);
|
||||
|
||||
@@ -83,16 +83,17 @@ export class SidebarPart extends CompositePart<Viewlet> implements ISidebar {
|
||||
}
|
||||
|
||||
// First check if sidebar is hidden and show if so
|
||||
let promise = TPromise.as(null);
|
||||
if (!this.partService.isVisible(Parts.SIDEBAR_PART)) {
|
||||
try {
|
||||
this.blockOpeningViewlet = true;
|
||||
this.partService.setSideBarHidden(false);
|
||||
promise = this.partService.setSideBarHidden(false);
|
||||
} finally {
|
||||
this.blockOpeningViewlet = false;
|
||||
}
|
||||
}
|
||||
|
||||
return this.openComposite(id, focus);
|
||||
return promise.then(() => this.openComposite(id, focus));
|
||||
}
|
||||
|
||||
public getActiveViewlet(): IViewlet {
|
||||
@@ -122,21 +123,18 @@ class FocusSideBarAction extends Action {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
public run(): TPromise<boolean> {
|
||||
public run(): TPromise<any> {
|
||||
|
||||
// Show side bar
|
||||
if (!this.partService.isVisible(Parts.SIDEBAR_PART)) {
|
||||
this.partService.setSideBarHidden(false);
|
||||
return this.partService.setSideBarHidden(false);
|
||||
}
|
||||
|
||||
// Focus into active viewlet
|
||||
else {
|
||||
let viewlet = this.viewletService.getActiveViewlet();
|
||||
if (viewlet) {
|
||||
viewlet.focus();
|
||||
}
|
||||
let viewlet = this.viewletService.getActiveViewlet();
|
||||
if (viewlet) {
|
||||
viewlet.focus();
|
||||
}
|
||||
|
||||
return TPromise.as(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user