Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)

* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998

* fix pipelines

* fix strict-null-checks

* add missing files
This commit is contained in:
Anthony Dresser
2019-10-21 22:12:22 -07:00
committed by GitHub
parent 7c9be74970
commit 1e22f47304
913 changed files with 18898 additions and 16536 deletions

View File

@@ -21,7 +21,7 @@ import { ActivePanelContext, PanelPositionContext } from 'vs/workbench/common/pa
export class ClosePanelAction extends Action {
static readonly ID = 'workbench.action.closePanel';
static LABEL = nls.localize('closePanel', "Close Panel");
static readonly LABEL = nls.localize('closePanel', "Close Panel");
constructor(
id: string,
@@ -40,7 +40,7 @@ export class ClosePanelAction extends Action {
export class TogglePanelAction extends Action {
static readonly ID = 'workbench.action.togglePanel';
static LABEL = nls.localize('togglePanel', "Toggle Panel");
static readonly LABEL = nls.localize('togglePanel', "Toggle Panel");
constructor(
id: string,
@@ -209,7 +209,7 @@ export class SwitchPanelViewAction extends Action {
export class PreviousPanelViewAction extends SwitchPanelViewAction {
static readonly ID = 'workbench.action.previousPanelView';
static LABEL = nls.localize('previousPanelView', 'Previous Panel View');
static readonly LABEL = nls.localize('previousPanelView', 'Previous Panel View');
constructor(
id: string,
@@ -227,7 +227,7 @@ export class PreviousPanelViewAction extends SwitchPanelViewAction {
export class NextPanelViewAction extends SwitchPanelViewAction {
static readonly ID = 'workbench.action.nextPanelView';
static LABEL = nls.localize('nextPanelView', 'Next Panel View');
static readonly LABEL = nls.localize('nextPanelView', 'Next Panel View');
constructor(
id: string,

View File

@@ -5,7 +5,7 @@
import 'vs/css!./media/panelpart';
import { IAction } from 'vs/base/common/actions';
import { Event, Emitter } from 'vs/base/common/event';
import { Event } from 'vs/base/common/event';
import { Registry } from 'vs/platform/registry/common/platform';
import { ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
import { IPanel, ActivePanelContext, PanelFocusContext } from 'vs/workbench/common/panel';
@@ -30,7 +30,7 @@ import { Dimension, trackFocus } from 'vs/base/browser/dom';
import { localize } from 'vs/nls';
import { IDisposable } from 'vs/base/common/lifecycle';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { isUndefinedOrNull, withUndefinedAsNull, withNullAsUndefined } from 'vs/base/common/types';
import { isUndefinedOrNull, assertIsDefined } from 'vs/base/common/types';
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
@@ -60,28 +60,25 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
readonly snap = true;
get preferredHeight(): number | undefined {
const sidebarDimension = this.layoutService.getDimension(Parts.SIDEBAR_PART);
return sidebarDimension.height * 0.4;
// Don't worry about titlebar or statusbar visibility
// The difference is minimal and keeps this function clean
return this.layoutService.dimension.height * 0.4;
}
get preferredWidth(): number | undefined {
const statusbarPart = this.layoutService.getDimension(Parts.STATUSBAR_PART);
return statusbarPart.width * 0.4;
return this.layoutService.dimension.width * 0.4;
}
//#endregion
get onDidPanelOpen(): Event<{ panel: IPanel, focus: boolean }> { return Event.map(this.onDidCompositeOpen.event, compositeOpen => ({ panel: compositeOpen.composite, focus: compositeOpen.focus })); }
get onDidPanelOpen(): Event<{ panel: IPanel, focus: boolean; }> { return Event.map(this.onDidCompositeOpen.event, compositeOpen => ({ panel: compositeOpen.composite, focus: compositeOpen.focus })); }
readonly onDidPanelClose: Event<IPanel> = this.onDidCompositeClose.event;
private _onDidVisibilityChange = this._register(new Emitter<boolean>());
readonly onDidVisibilityChange: Event<boolean> = this._onDidVisibilityChange.event;
private activePanelContextKey: IContextKey<string>;
private panelFocusContextKey: IContextKey<boolean>;
private compositeBar: CompositeBar;
private compositeActions: Map<string, { activityAction: PanelActivityAction, pinnedAction: ToggleCompositePinnedAction }> = new Map();
private compositeActions: Map<string, { activityAction: PanelActivityAction, pinnedAction: ToggleCompositePinnedAction; }> = new Map();
private blockOpeningPanel = false;
private _contentDimension: Dimension | undefined;
@@ -123,7 +120,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
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)),
getOnCompositeClickAction: (compositeId: string) => this.instantiationService.createInstance(PanelActivityAction, assertIsDefined(this.getPanel(compositeId))),
getContextMenuActions: () => [
this.instantiationService.createInstance(TogglePanelPositionAction, TogglePanelPositionAction.ID, TogglePanelPositionAction.LABEL),
this.instantiationService.createInstance(TogglePanelAction, TogglePanelAction.ID, localize('hidePanel', "Hide Panel"))
@@ -208,19 +205,19 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
updateStyles(): void {
super.updateStyles();
const container = this.getContainer();
container.style.backgroundColor = this.getColor(PANEL_BACKGROUND);
container.style.borderLeftColor = this.getColor(PANEL_BORDER) || this.getColor(contrastBorder);
const container = assertIsDefined(this.getContainer());
container.style.backgroundColor = this.getColor(PANEL_BACKGROUND) || '';
container.style.borderLeftColor = this.getColor(PANEL_BORDER) || this.getColor(contrastBorder) || '';
const title = this.getTitleArea();
if (title) {
title.style.borderTopColor = this.getColor(PANEL_BORDER) || this.getColor(contrastBorder);
title.style.borderTopColor = this.getColor(PANEL_BORDER) || this.getColor(contrastBorder) || '';
}
}
openPanel(id: string, focus?: boolean): Panel | null {
openPanel(id: string, focus?: boolean): Panel | undefined {
if (this.blockOpeningPanel) {
return null; // Workaround against a potential race condition
return undefined; // Workaround against a potential race condition
}
// First check if panel is hidden and show if so
@@ -233,7 +230,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
}
return withUndefinedAsNull(this.openComposite(id, focus));
return this.openComposite(id, focus);
}
showActivity(panelId: string, badge: IBadge, clazz?: string): IDisposable {
@@ -241,15 +238,15 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
getPanel(panelId: string): IPanelIdentifier | undefined {
return withNullAsUndefined(Registry.as<PanelRegistry>(PanelExtensions.Panels).getPanel(panelId));
return Registry.as<PanelRegistry>(PanelExtensions.Panels).getPanel(panelId);
}
getPanels(): PanelDescriptor[] {
getPanels(): readonly PanelDescriptor[] {
return Registry.as<PanelRegistry>(PanelExtensions.Panels).getPanels()
.sort((v1, v2) => typeof v1.order === 'number' && typeof v2.order === 'number' ? v1.order - v2.order : NaN);
}
getPinnedPanels(): PanelDescriptor[] {
getPinnedPanels(): readonly PanelDescriptor[] {
const pinnedCompositeIds = this.compositeBar.getPinnedComposites().map(c => c.id);
return this.getPanels()
.filter(p => pinnedCompositeIds.indexOf(p.id) !== -1)
@@ -263,7 +260,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
];
}
getActivePanel(): IPanel | null {
getActivePanel(): IPanel | undefined {
return this.getActiveComposite();
}
@@ -303,9 +300,9 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
if (this.layoutService.getPanelPosition() === Position.RIGHT) {
this._contentDimension = new Dimension(width - 1, height!); // Take into account the 1px border when layouting
this._contentDimension = new Dimension(width - 1, height); // Take into account the 1px border when layouting
} else {
this._contentDimension = new Dimension(width, height!);
this._contentDimension = new Dimension(width, height);
}
// Layout contents
@@ -316,7 +313,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
private layoutCompositeBar(): void {
if (this._contentDimension) {
if (this._contentDimension && this.dimension) {
let availableWidth = this._contentDimension.width - 40; // take padding into account
if (this.toolBar) {
availableWidth = Math.max(PanelPart.MIN_COMPOSITE_BAR_WIDTH, availableWidth - this.getToolbarWidth()); // adjust height for global actions showing
@@ -326,11 +323,11 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
}
private getCompositeActions(compositeId: string): { activityAction: PanelActivityAction, pinnedAction: ToggleCompositePinnedAction } {
private getCompositeActions(compositeId: string): { activityAction: PanelActivityAction, pinnedAction: ToggleCompositePinnedAction; } {
let compositeActions = this.compositeActions.get(compositeId);
if (!compositeActions) {
compositeActions = {
activityAction: this.instantiationService.createInstance(PanelActivityAction, this.getPanel(compositeId)),
activityAction: this.instantiationService.createInstance(PanelActivityAction, assertIsDefined(this.getPanel(compositeId))),
pinnedAction: new ToggleCompositePinnedAction(this.getPanel(compositeId), this.compositeBar)
};
@@ -357,7 +354,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
private getToolbarWidth(): number {
const activePanel = this.getActivePanel();
if (!activePanel) {
if (!activePanel || !this.toolBar) {
return 0;
}
@@ -446,10 +443,6 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
this.storageService.store(PanelPart.PINNED_PANELS, value, StorageScope.GLOBAL);
}
setVisible(visible: boolean): void {
this._onDidVisibilityChange.fire(visible);
}
toJSON(): object {
return {
type: Parts.PANEL_PART