Merge from vscode 52dcb723a39ae75bee1bd56b3312d7fcdc87aeed (#6719)

This commit is contained in:
Anthony Dresser
2019-08-12 21:31:51 -07:00
committed by GitHub
parent 00250839fc
commit 7eba8c4c03
616 changed files with 9472 additions and 7087 deletions

View File

@@ -48,7 +48,7 @@ interface ICachedViewlet {
export class ActivitybarPart extends Part implements IActivityBarService {
_serviceBrand: ServiceIdentifier<any>;
_serviceBrand!: ServiceIdentifier<any>;
private static readonly ACTION_HEIGHT = 48;
private static readonly PINNED_VIEWLETS = 'workbench.activity.pinnedViewlets';

View File

@@ -46,10 +46,10 @@ export interface ICompositeBarOptions {
export class CompositeBar extends Widget implements ICompositeBar {
private dimension: Dimension;
private dimension: Dimension | undefined;
private compositeSwitcherBar: ActionBar;
private compositeOverflowAction: CompositeOverflowActivityAction | null;
private compositeSwitcherBar!: ActionBar;
private compositeOverflowAction: CompositeOverflowActivityAction | undefined;
private compositeOverflowActionViewItem: CompositeOverflowActivityActionViewItem | undefined;
private model: CompositeBarModel;
@@ -343,7 +343,7 @@ export class CompositeBar extends Widget implements ICompositeBar {
this.compositeSwitcherBar.pull(this.compositeSwitcherBar.length() - 1);
this.compositeOverflowAction.dispose();
this.compositeOverflowAction = null;
this.compositeOverflowAction = undefined;
if (this.compositeOverflowActionViewItem) {
this.compositeOverflowActionViewItem.dispose();
@@ -460,7 +460,7 @@ interface ICompositeBarModelItem extends ICompositeBarItem {
class CompositeBarModel {
private _items: ICompositeBarModelItem[];
private _items: ICompositeBarModelItem[] = [];
private readonly options: ICompositeBarOptions;
activeItem?: ICompositeBarModelItem;

View File

@@ -124,12 +124,12 @@ export interface IActivityActionViewItemOptions extends IBaseActionViewItemOptio
}
export class ActivityActionViewItem extends BaseActionViewItem {
protected container: HTMLElement;
protected label: HTMLElement;
protected badge: HTMLElement;
protected options: IActivityActionViewItemOptions;
protected container!: HTMLElement;
protected label!: HTMLElement;
protected badge!: HTMLElement;
protected options!: IActivityActionViewItemOptions;
private badgeContent: HTMLElement;
private badgeContent: HTMLElement | undefined;
private readonly badgeDisposable = this._register(new MutableDisposable());
private mouseUpTimeout: any;
@@ -347,7 +347,7 @@ export class CompositeOverflowActivityAction extends ActivityAction {
}
export class CompositeOverflowActivityActionViewItem extends ActivityActionViewItem {
private actions: Action[];
private actions: Action[] | undefined;
constructor(
action: ActivityAction,
@@ -371,8 +371,8 @@ export class CompositeOverflowActivityActionViewItem extends ActivityActionViewI
this.contextMenuService.showContextMenu({
getAnchor: () => this.element!,
getActions: () => this.actions,
onHide: () => dispose(this.actions)
getActions: () => this.actions!,
onHide: () => dispose(this.actions!)
});
}
@@ -402,7 +402,9 @@ export class CompositeOverflowActivityActionViewItem extends ActivityActionViewI
dispose(): void {
super.dispose();
this.actions = dispose(this.actions);
if (this.actions) {
this.actions = dispose(this.actions);
}
}
}
@@ -431,7 +433,7 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
private static manageExtensionAction: ManageExtensionAction;
private compositeActivity: IActivity | null;
private compositeActivity: IActivity | undefined;
private compositeTransfer: LocalSelectionTransfer<DraggedCompositeIdentifier>;
constructor(
@@ -454,7 +456,7 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
CompositeActionViewItem.manageExtensionAction = instantiationService.createInstance(ManageExtensionAction);
}
this._register(compositeActivityAction.onDidChangeActivity(() => { this.compositeActivity = null; this.updateActivity(); }, this));
this._register(compositeActivityAction.onDidChangeActivity(() => { this.compositeActivity = undefined; this.updateActivity(); }, this));
}
protected get activity(): IActivity {

View File

@@ -58,18 +58,18 @@ export abstract class CompositePart<T extends Composite> extends Part {
protected readonly onDidCompositeOpen = this._register(new Emitter<{ composite: IComposite, focus: boolean }>());
protected readonly onDidCompositeClose = this._register(new Emitter<IComposite>());
protected toolBar: ToolBar;
protected toolBar!: ToolBar;
private mapCompositeToCompositeContainer = new Map<string, HTMLElement>();
private mapActionsBindingToComposite = new Map<string, () => void>();
private activeComposite: Composite | null;
private lastActiveCompositeId: string;
private instantiatedCompositeItems: Map<string, CompositeItem>;
private titleLabel: ICompositeTitleLabel;
private progressBar: ProgressBar;
private contentAreaSize: Dimension;
private titleLabel!: ICompositeTitleLabel;
private progressBar!: ProgressBar;
private contentAreaSize: Dimension | undefined;
private readonly telemetryActionsListener = this._register(new MutableDisposable());
private currentCompositeOpenToken: string;
private currentCompositeOpenToken: string | undefined;
constructor(
private notificationService: INotificationService,

View File

@@ -29,7 +29,7 @@ export interface IBreadcrumbsService {
export class BreadcrumbsService implements IBreadcrumbsService {
_serviceBrand: ServiceIdentifier<any>;
_serviceBrand: any;
private readonly _map = new Map<number, BreadcrumbsWidget>();
@@ -55,8 +55,8 @@ registerSingleton(IBreadcrumbsService, BreadcrumbsService, true);
export abstract class BreadcrumbsConfig<T> {
name: string;
onDidChange: Event<void>;
abstract get name(): string;
abstract get onDidChange(): Event<void>;
abstract getValue(overrides?: IConfigurationOverrides): T;
abstract updateValue(value: T, overrides?: IConfigurationOverrides): Promise<void>;

View File

@@ -56,11 +56,11 @@ export abstract class BreadcrumbsPicker {
protected readonly _disposables = new DisposableStore();
protected readonly _domNode: HTMLDivElement;
protected _arrow: HTMLDivElement;
protected _treeContainer: HTMLDivElement;
protected _tree: Tree<any, any>;
protected _arrow!: HTMLDivElement;
protected _treeContainer!: HTMLDivElement;
protected _tree!: Tree<any, any>;
protected _fakeEvent = new UIEvent('fakeEvent');
protected _layoutInfo: ILayoutInfo;
protected _layoutInfo!: ILayoutInfo;
private readonly _onDidPickElement = new Emitter<SelectEvent>();
readonly onDidPickElement: Event<SelectEvent> = this._onDidPickElement.event;

View File

@@ -36,7 +36,7 @@ import {
SplitEditorUpAction, SplitEditorDownAction, MoveEditorToLeftGroupAction, MoveEditorToRightGroupAction, MoveEditorToAboveGroupAction, MoveEditorToBelowGroupAction, CloseAllEditorGroupsAction,
JoinAllGroupsAction, FocusLeftGroup, FocusAboveGroup, FocusRightGroup, FocusBelowGroup, EditorLayoutSingleAction, EditorLayoutTwoColumnsAction, EditorLayoutThreeColumnsAction, EditorLayoutTwoByTwoGridAction,
EditorLayoutTwoRowsAction, EditorLayoutThreeRowsAction, EditorLayoutTwoColumnsBottomAction, EditorLayoutTwoRowsRightAction, NewEditorGroupLeftAction, NewEditorGroupRightAction,
NewEditorGroupAboveAction, NewEditorGroupBelowAction, SplitEditorOrthogonalAction, CloseEditorInAllGroupsAction, NavigateToLastEditLocationAction
NewEditorGroupAboveAction, NewEditorGroupBelowAction, SplitEditorOrthogonalAction, CloseEditorInAllGroupsAction, NavigateToLastEditLocationAction, ToggleGroupSizesAction
} from 'vs/workbench/browser/parts/editor/editorActions';
import * as editorCommands from 'vs/workbench/browser/parts/editor/editorCommands';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
@@ -339,6 +339,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(JoinTwoGroupsAction, J
registry.registerWorkbenchAction(new SyncActionDescriptor(JoinAllGroupsAction, JoinAllGroupsAction.ID, JoinAllGroupsAction.LABEL), 'View: Join All Editor Groups', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(NavigateBetweenGroupsAction, NavigateBetweenGroupsAction.ID, NavigateBetweenGroupsAction.LABEL), 'View: Navigate Between Editor Groups', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ResetGroupSizesAction, ResetGroupSizesAction.ID, ResetGroupSizesAction.LABEL), 'View: Reset Editor Group Sizes', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleGroupSizesAction, ToggleGroupSizesAction.ID, ToggleGroupSizesAction.LABEL), 'View: Toggle Editor Group Sizes', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(MaximizeGroupAction, MaximizeGroupAction.ID, MaximizeGroupAction.LABEL), 'View: Maximize Editor Group and Hide Side Bar', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(MinimizeOtherGroupsAction, MinimizeOtherGroupsAction.ID, MinimizeOtherGroupsAction.LABEL), 'View: Maximize Editor Group', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(MoveEditorLeftInGroupAction, MoveEditorLeftInGroupAction.ID, MoveEditorLeftInGroupAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.PageUp, mac: { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.LeftArrow) } }), 'View: Move Editor Left', category);

View File

@@ -81,12 +81,15 @@ export interface IEditorOpeningEvent extends IEditorIdentifier {
}
export interface IEditorGroupsAccessor {
readonly groups: IEditorGroupView[];
readonly activeGroup: IEditorGroupView;
readonly partOptions: IEditorPartOptions;
readonly onDidEditorPartOptionsChange: Event<IEditorPartOptionsChangeEvent>;
readonly onDidVisibilityChange: Event<boolean>;
getGroup(identifier: GroupIdentifier): IEditorGroupView | undefined;
getGroups(order: GroupsOrder): IEditorGroupView[];
@@ -106,6 +109,9 @@ export interface IEditorGroupView extends IDisposable, ISerializableView, IEdito
readonly whenRestored: Promise<void>;
readonly disposed: boolean;
readonly isEmpty: boolean;
readonly isMinimized: boolean;
readonly onDidFocus: Event<void>;
readonly onWillDispose: Event<void>;
readonly onWillOpenEditor: Event<IEditorOpeningEvent>;
@@ -113,9 +119,10 @@ export interface IEditorGroupView extends IDisposable, ISerializableView, IEdito
readonly onWillCloseEditor: Event<IEditorCloseEvent>;
readonly onDidCloseEditor: Event<IEditorCloseEvent>;
isEmpty(): boolean;
setActive(isActive: boolean): void;
setLabel(label: string): void;
notifyIndexChanged(newIndex: number): void;
relayout(): void;
}

View File

@@ -880,6 +880,22 @@ export class ResetGroupSizesAction extends Action {
}
}
export class ToggleGroupSizesAction extends Action {
static readonly ID = 'workbench.action.toggleEditorWidths';
static readonly LABEL = nls.localize('toggleEditorWidths', "Toggle Editor Group Sizes");
constructor(id: string, label: string, @IEditorGroupsService private readonly editorGroupService: IEditorGroupsService) {
super(id, label);
}
run(): Promise<any> {
this.editorGroupService.arrangeGroups(GroupsArrangement.TOGGLE);
return Promise.resolve(false);
}
}
export class MaximizeGroupAction extends Action {
static readonly ID = 'workbench.action.maximizeEditor';

View File

@@ -221,6 +221,12 @@ export class EditorControl extends Disposable {
}
}
setVisible(visible: boolean): void {
if (this._activeControl) {
this._activeControl.setVisible(visible, this.groupView);
}
}
layout(dimension: Dimension): void {
this.dimension = dimension;

View File

@@ -409,7 +409,7 @@ class DropOverlay extends Themable {
}
private getOverlayOffsetHeight(): number {
if (!this.groupView.isEmpty() && this.accessor.partOptions.showTabs) {
if (!this.groupView.isEmpty && this.accessor.partOptions.showTabs) {
return EDITOR_TITLE_HEIGHT; // show overlay below title if group shows tabs
}

View File

@@ -58,16 +58,16 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
//#region factory
static createNew(accessor: IEditorGroupsAccessor, label: string, instantiationService: IInstantiationService): IEditorGroupView {
return instantiationService.createInstance(EditorGroupView, accessor, null, label);
static createNew(accessor: IEditorGroupsAccessor, index: number, instantiationService: IInstantiationService): IEditorGroupView {
return instantiationService.createInstance(EditorGroupView, accessor, null, index);
}
static createFromSerialized(serialized: ISerializedEditorGroup, accessor: IEditorGroupsAccessor, label: string, instantiationService: IInstantiationService): IEditorGroupView {
return instantiationService.createInstance(EditorGroupView, accessor, serialized, label);
static createFromSerialized(serialized: ISerializedEditorGroup, accessor: IEditorGroupsAccessor, index: number, instantiationService: IInstantiationService): IEditorGroupView {
return instantiationService.createInstance(EditorGroupView, accessor, serialized, index);
}
static createCopy(copyFrom: IEditorGroupView, accessor: IEditorGroupsAccessor, label: string, instantiationService: IInstantiationService): IEditorGroupView {
return instantiationService.createInstance(EditorGroupView, accessor, copyFrom, label);
static createCopy(copyFrom: IEditorGroupView, accessor: IEditorGroupsAccessor, index: number, instantiationService: IInstantiationService): IEditorGroupView {
return instantiationService.createInstance(EditorGroupView, accessor, copyFrom, index);
}
//#endregion
@@ -123,7 +123,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
constructor(
private accessor: IEditorGroupsAccessor,
from: IEditorGroupView | ISerializedEditorGroup,
private _label: string,
private _index: number,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IThemeService themeService: IThemeService,
@@ -256,7 +256,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
// Open new file via doubleclick on empty container
this._register(addDisposableListener(this.element, EventType.DBLCLICK, e => {
if (this.isEmpty()) {
if (this.isEmpty) {
EventHelper.stop(e);
// {{SQL CARBON EDIT}}
this.commandService.executeCommand(GlobalNewUntitledFileAction.ID).then(undefined, err => this.notificationService.warn(err));
@@ -265,7 +265,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
// Close empty editor group via middle mouse click
this._register(addDisposableListener(this.element, EventType.MOUSE_UP, e => {
if (this.isEmpty() && e.button === 1 /* Middle Button */) {
if (this.isEmpty && e.button === 1 /* Middle Button */) {
EventHelper.stop(e);
this.accessor.removeGroup(this);
@@ -314,7 +314,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
}
private onShowContainerContextMenu(menu: IMenu, e?: MouseEvent): void {
if (!this.isEmpty()) {
if (!this.isEmpty) {
return; // only for empty editor groups
}
@@ -345,7 +345,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
// Container
const containerFocusTracker = this._register(trackFocus(this.element));
this._register(containerFocusTracker.onDidFocus(() => {
if (this.isEmpty()) {
if (this.isEmpty) {
this._onDidFocus.fire(); // only when empty to prevent accident focus
}
}));
@@ -387,7 +387,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
private updateContainer(): void {
// Empty Container: add some empty container attributes
if (this.isEmpty()) {
if (this.isEmpty) {
addClass(this.element, 'empty');
this.element.tabIndex = 0;
this.element.setAttribute('aria-label', localize('emptyEditorGroup', "{0} (empty)", this.label));
@@ -474,6 +474,9 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
// Option Changes
this._register(this.accessor.onDidEditorPartOptionsChange(e => this.onDidEditorPartOptionsChange(e)));
// Visibility
this._register(this.accessor.onDidVisibilityChange(e => this.onDidVisibilityChange(e)));
}
private onDidEditorPin(editor: EditorInput): void {
@@ -597,8 +600,12 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
// Title control Switch between showing tabs <=> not showing tabs
if (event.oldPartOptions.showTabs !== event.newPartOptions.showTabs) {
this.createTitleAreaControl();
// Recreate and layout control
this.createTitleAreaControl();
this.layoutTitleAreaControl();
// Ensure to show active editor if any
if (this._group.activeEditor) {
this.titleAreaControl.openEditor(this._group.activeEditor);
}
@@ -641,6 +648,12 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
this._onDidGroupChange.fire({ kind: GroupChangeKind.EDITOR_LABEL, editor });
}
private onDidVisibilityChange(visible: boolean): void {
// Forward to editor control
this.editorControl.setVisible(visible);
}
//#endregion
//region IEditorGroupView
@@ -649,8 +662,12 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
return this._group;
}
get index(): number {
return this._index;
}
get label(): string {
return this._label;
return localize('groupLabel', "Group {0}", this._index + 1);
}
get disposed(): boolean {
@@ -661,10 +678,22 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
return this._whenRestored;
}
setLabel(label: string): void {
if (this._label !== label) {
this._label = label;
this._onDidGroupChange.fire({ kind: GroupChangeKind.GROUP_LABEL });
get isEmpty(): boolean {
return this._group.count === 0;
}
get isMinimized(): boolean {
if (!this.dimension) {
return false;
}
return this.dimension.width === this.minimumWidth || this.dimension.height === this.minimumHeight;
}
notifyIndexChanged(newIndex: number): void {
if (this._index !== newIndex) {
this._index = newIndex;
this._onDidGroupChange.fire({ kind: GroupChangeKind.GROUP_INDEX });
}
}
@@ -685,10 +714,6 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
this._onDidGroupChange.fire({ kind: GroupChangeKind.GROUP_ACTIVE });
}
isEmpty(): boolean {
return this._group.count === 0;
}
//#endregion
//#region IEditorGroup
@@ -1213,7 +1238,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
//#region closeEditors()
async closeEditors(args: EditorInput[] | ICloseEditorsFilter, options?: ICloseEditorOptions): Promise<void> {
if (this.isEmpty()) {
if (this.isEmpty) {
return;
}
@@ -1285,7 +1310,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
//#region closeAllEditors()
async closeAllEditors(): Promise<void> {
if (this.isEmpty()) {
if (this.isEmpty) {
// If the group is empty and the request is to close all editors, we still close
// the editor group is the related setting to close empty groups is enabled for
@@ -1397,7 +1422,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
//#region Themable
protected updateStyles(): void {
const isEmpty = this.isEmpty();
const isEmpty = this.isEmpty;
// Container
if (isEmpty) {
@@ -1446,10 +1471,14 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
this.editorContainer.style.height = `calc(100% - ${this.titleAreaControl.getPreferredHeight()}px)`;
// Forward to controls
this.titleAreaControl.layout(new Dimension(this.dimension.width, this.titleAreaControl.getPreferredHeight()));
this.layoutTitleAreaControl();
this.editorControl.layout(new Dimension(this.dimension.width, this.dimension.height - this.titleAreaControl.getPreferredHeight()));
}
private layoutTitleAreaControl(): void {
this.titleAreaControl.layout(new Dimension(this.dimension.width, this.titleAreaControl.getPreferredHeight()));
}
relayout(): void {
if (this.dimension) {
const { width, height } = this.dimension;
@@ -1469,7 +1498,6 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
this._onWillDispose.fire();
this.titleAreaControl.dispose();
// this.editorControl = null;
super.dispose();
}

View File

@@ -24,7 +24,6 @@ import { assign } from 'vs/base/common/objects';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { ISerializedEditorGroup, isSerializedEditorGroup } from 'vs/workbench/common/editor/editorGroup';
import { EditorDropTarget } from 'vs/workbench/browser/parts/editor/editorDropTarget';
import { localize } from 'vs/nls';
import { Color } from 'vs/base/common/color';
import { CenteredViewLayout } from 'vs/base/browser/ui/centered/centeredViewLayout';
import { onUnexpectedError } from 'vs/base/common/errors';
@@ -82,7 +81,7 @@ class GridWidgetView<T extends IView> implements IView {
export class EditorPart extends Part implements IEditorGroupsService, IEditorGroupsAccessor {
_serviceBrand: ServiceIdentifier<any>;
_serviceBrand!: ServiceIdentifier<any>;
private static readonly EDITOR_PART_UI_STATE_STORAGE_KEY = 'editorpart.state';
private static readonly EDITOR_PART_CENTERED_VIEW_STORAGE_KEY = 'editorpart.centeredview';
@@ -95,6 +94,9 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
private readonly _onDidActiveGroupChange: Emitter<IEditorGroupView> = this._register(new Emitter<IEditorGroupView>());
readonly onDidActiveGroupChange: Event<IEditorGroupView> = this._onDidActiveGroupChange.event;
private readonly _onDidGroupIndexChange: Emitter<IEditorGroupView> = this._register(new Emitter<IEditorGroupView>());
readonly onDidGroupIndexChange: Event<IEditorGroupView> = this._onDidGroupIndexChange.event;
private readonly _onDidActivateGroup: Emitter<IEditorGroupView> = this._register(new Emitter<IEditorGroupView>());
readonly onDidActivateGroup: Event<IEditorGroupView> = this._onDidActivateGroup.event;
@@ -344,15 +346,36 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
return; // we have not been created yet
}
// Even all group sizes
if (arrangement === GroupsArrangement.EVEN) {
this.gridWidget.distributeViewSizes();
switch (arrangement) {
case GroupsArrangement.EVEN:
this.gridWidget.distributeViewSizes();
break;
case GroupsArrangement.MINIMIZE_OTHERS:
this.gridWidget.maximizeViewSize(this.activeGroup);
break;
case GroupsArrangement.TOGGLE:
if (this.isGroupMaximized(this.activeGroup)) {
this.arrangeGroups(GroupsArrangement.EVEN);
} else {
this.arrangeGroups(GroupsArrangement.MINIMIZE_OTHERS);
}
break;
}
}
private isGroupMaximized(targetGroup: IEditorGroupView): boolean {
for (const group of this.groups) {
if (group === targetGroup) {
continue; // ignore target group
}
if (!group.isMinimized) {
return false; // target cannot be maximized if one group is not minimized
}
}
// Maximize the current active group
else {
this.gridWidget.maximizeViewSize(this.activeGroup);
}
return true;
}
setGroupOrientation(orientation: GroupOrientation): void {
@@ -424,8 +447,8 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
}
});
// Update labels
this.updateGroupLabels();
// Notify group index change given layout has changed
this.notifyGroupIndexChange();
// Restore focus as needed
if (restoreFocus) {
@@ -484,25 +507,22 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
// Event
this._onDidAddGroup.fire(newGroupView);
// Update labels
this.updateGroupLabels();
// Notify group index change given a new group was added
this.notifyGroupIndexChange();
return newGroupView;
}
private doCreateGroupView(from?: IEditorGroupView | ISerializedEditorGroup | null): IEditorGroupView {
// Label: just use the number of existing groups as label
const label = this.getGroupLabel(this.count + 1);
// Create group view
let groupView: IEditorGroupView;
if (from instanceof EditorGroupView) {
groupView = EditorGroupView.createCopy(from, this, label, this.instantiationService);
groupView = EditorGroupView.createCopy(from, this, this.count, this.instantiationService);
} else if (isSerializedEditorGroup(from)) {
groupView = EditorGroupView.createFromSerialized(from, this, label, this.instantiationService);
groupView = EditorGroupView.createFromSerialized(from, this, this.count, this.instantiationService);
} else {
groupView = EditorGroupView.createNew(this, label, this.instantiationService);
groupView = EditorGroupView.createNew(this, this.count, this.instantiationService);
}
// Keep in map
@@ -516,8 +536,13 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
// Track editor change
groupDisposables.add(groupView.onDidGroupChange(e => {
if (e.kind === GroupChangeKind.EDITOR_ACTIVE) {
this.updateContainer();
switch (e.kind) {
case GroupChangeKind.EDITOR_ACTIVE:
this.updateContainer();
break;
case GroupChangeKind.GROUP_INDEX:
this._onDidGroupIndexChange.fire(groupView);
break;
}
}));
@@ -600,7 +625,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
}
// Remove empty group
if (groupView.isEmpty()) {
if (groupView.isEmpty) {
return this.doRemoveEmptyGroup(groupView);
}
@@ -643,8 +668,8 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
this._activeGroup.focus();
}
// Update labels
this.updateGroupLabels();
// Notify group index change given a group was removed
this.notifyGroupIndexChange();
// Update container
this.updateContainer();
@@ -675,6 +700,9 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
// Event
this._onDidMoveGroup.fire(sourceView);
// Notify group index change given a group was moved
this.notifyGroupIndexChange();
return sourceView;
}
@@ -715,7 +743,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
});
// Remove source if the view is now empty and not already removed
if (sourceView.isEmpty() && !sourceView.disposed /* could have been disposed already via workbench.editor.closeEmptyGroups setting */) {
if (sourceView.isEmpty && !sourceView.disposed /* could have been disposed already via workbench.editor.closeEmptyGroups setting */) {
this.removeGroup(sourceView);
}
@@ -784,6 +812,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
centerLayout(active: boolean): void {
this.centeredLayoutWidget.activate(active);
this._activeGroup.focus();
}
@@ -813,6 +842,9 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
// Update container
this.updateContainer();
// Notify group index change we created the entire grid
this.notifyGroupIndexChange();
}
private doCreateGridControlWithPreviousState(): boolean {
@@ -906,26 +938,15 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
}
private updateContainer(): void {
toggleClass(this.container, 'empty', this.isEmpty());
toggleClass(this.container, 'empty', this.isEmpty);
}
private updateGroupLabels(): void {
// Since our labels are created using the index of the
// group, adding/removing a group might produce gaps.
// So we iterate over all groups and reassign the label
// based on the index.
this.getGroups(GroupsOrder.GRID_APPEARANCE).forEach((group, index) => {
group.setLabel(this.getGroupLabel(index + 1));
});
private notifyGroupIndexChange(): void {
this.getGroups(GroupsOrder.GRID_APPEARANCE).forEach((group, index) => group.notifyIndexChanged(index));
}
private getGroupLabel(index: number): string {
return localize('groupLabel', "Group {0}", index);
}
private isEmpty(): boolean {
return this.groupViews.size === 1 && this._activeGroup.isEmpty();
private get isEmpty(): boolean {
return this.groupViews.size === 1 && this._activeGroup.isEmpty;
}
layout(width: number, height: number): void {
@@ -957,7 +978,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
mostRecentActiveGroups: this.mostRecentActiveGroups
};
if (this.isEmpty()) {
if (this.isEmpty) {
delete this.workspaceMemento[EditorPart.EDITOR_PART_UI_STATE_STORAGE_KEY];
} else {
this.workspaceMemento[EditorPart.EDITOR_PART_UI_STATE_STORAGE_KEY] = uiState;

View File

@@ -285,4 +285,4 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
if (notificationBorderColor) {
collector.addRule(`.monaco-workbench > .notifications-center .notifications-list-container .monaco-list-row[data-last-element="false"] > .notification-list-item { border-bottom: 1px solid ${notificationBorderColor}; }`);
}
});
});

View File

@@ -11,12 +11,12 @@ import { localize } from 'vs/nls';
export class NotificationsStatus extends Disposable {
private notificationsCenterStatusItem: IStatusbarEntryAccessor;
private notificationsCenterStatusItem: IStatusbarEntryAccessor | undefined;
private currentNotifications = new Set<INotificationViewItem>();
private currentStatusMessage: [IStatusMessageViewItem, IDisposable] | undefined;
private isNotificationsCenterVisible: boolean;
private isNotificationsCenterVisible: boolean | undefined;
constructor(
private model: INotificationsModel,
@@ -172,4 +172,4 @@ export class NotificationsStatus extends Disposable {
// Remember as current status message
this.currentStatusMessage = [item, statusMessageDispose];
}
}
}

View File

@@ -62,7 +62,7 @@ export class NotificationsListDelegate implements IListVirtualDelegate<INotifica
}
// Last row: source and buttons if we have any
if (notification.source || isNonEmptyArray(notification.actions.primary)) {
if (notification.source || isNonEmptyArray(notification.actions && notification.actions.primary)) {
expandedHeight += NotificationsListDelegate.ROW_HEIGHT;
}
@@ -82,7 +82,7 @@ export class NotificationsListDelegate implements IListVirtualDelegate<INotifica
if (notification.canCollapse) {
actions++; // expand/collapse
}
if (isNonEmptyArray(notification.actions.secondary)) {
if (isNonEmptyArray(notification.actions && notification.actions.secondary)) {
actions++; // secondary actions
}
this.offsetHelper.style.width = `calc(100% - ${10 /* padding */ + 24 /* severity icon */ + (actions * 24) /* 24px per action */}px)`;
@@ -392,8 +392,9 @@ export class NotificationTemplateRenderer extends Disposable {
const actions: IAction[] = [];
// Secondary Actions
if (isNonEmptyArray(notification.actions.secondary)) {
const configureNotificationAction = this.instantiationService.createInstance(ConfigureNotificationAction, ConfigureNotificationAction.ID, ConfigureNotificationAction.LABEL, notification.actions.secondary);
const secondaryActions = notification.actions ? notification.actions.secondary : undefined;
if (isNonEmptyArray(secondaryActions)) {
const configureNotificationAction = this.instantiationService.createInstance(ConfigureNotificationAction, ConfigureNotificationAction.ID, ConfigureNotificationAction.LABEL, secondaryActions);
actions.push(configureNotificationAction);
this.inputDisposables.add(configureNotificationAction);
}
@@ -435,10 +436,11 @@ export class NotificationTemplateRenderer extends Disposable {
private renderButtons(notification: INotificationViewItem): void {
clearNode(this.template.buttonsContainer);
if (notification.expanded && notification.actions.primary) {
const buttonGroup = new ButtonGroup(this.template.buttonsContainer, notification.actions.primary.length, { title: true /* assign titles to buttons in case they overflow */ });
const primaryActions = notification.actions ? notification.actions.primary : undefined;
if (notification.expanded && isNonEmptyArray(primaryActions)) {
const buttonGroup = new ButtonGroup(this.template.buttonsContainer, primaryActions.length, { title: true /* assign titles to buttons in case they overflow */ });
buttonGroup.buttons.forEach((button, index) => {
const action = notification.actions.primary![index];
const action = primaryActions[index];
button.label = action.label;
this.inputDisposables.add(button.onDidClick(e => {

View File

@@ -25,11 +25,19 @@
border-top-style: solid;
}
.monaco-workbench.noeditorarea .part.panel.bottom .title {
border-top-width: 0; /* no border when editor area is hiden */
}
.monaco-workbench .part.panel.right {
border-left-width: 1px;
border-left-style: solid;
}
.monaco-workbench.noeditorarea .part.panel.right {
border-left-width: 0; /* no border when editor area is hiden */
}
.monaco-workbench .part.panel > .title > .title-actions .monaco-action-bar .action-item .action-label {
outline-offset: -2px;
}
@@ -181,4 +189,4 @@
.hc-black .monaco-workbench .panel.right .minimize-panel-action {
background-image: url('chevron-right-hc.svg');
}
}

View File

@@ -48,7 +48,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
private static readonly PINNED_PANELS = 'workbench.panel.pinnedPanels';
private static readonly MIN_COMPOSITE_BAR_WIDTH = 50;
_serviceBrand: ServiceIdentifier<any>;
_serviceBrand!: ServiceIdentifier<any>;
//#region IView
@@ -83,8 +83,8 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
private compositeBar: CompositeBar;
private compositeActions: Map<string, { activityAction: PanelActivityAction, pinnedAction: ToggleCompositePinnedAction }> = new Map();
private blockOpeningPanel: boolean;
private _contentDimension: Dimension;
private blockOpeningPanel = false;
private _contentDimension: Dimension | undefined;
constructor(
@INotificationService notificationService: INotificationService,
@@ -367,7 +367,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
private onDidStorageChange(e: IWorkspaceStorageChangeEvent): void {
if (e.key === PanelPart.PINNED_PANELS && e.scope === StorageScope.GLOBAL
&& this.cachedPanelsValue !== this.getStoredCachedPanelsValue() /* This checks if current window changed the value or not */) {
this._cachedPanelsValue = null;
this._cachedPanelsValue = undefined;
const newCompositeItems: ICompositeBarItem[] = [];
const compositeItems = this.compositeBar.getCompositeBarItems();
const cachedPanels = this.getCachedPanels();
@@ -422,7 +422,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
return cachedPanels;
}
private _cachedPanelsValue: string | null;
private _cachedPanelsValue: string | undefined;
private get cachedPanelsValue(): string {
if (!this._cachedPanelsValue) {
this._cachedPanelsValue = this.getStoredCachedPanelsValue();

View File

@@ -880,7 +880,7 @@ class InputBox extends QuickInput implements IInputBox {
export class QuickInputService extends Component implements IQuickInputService {
public _serviceBrand: ServiceIdentifier<any>;
public _serviceBrand!: ServiceIdentifier<any>;
private static readonly ID = 'workbench.component.quickinput';
private static readonly MAX_WIDTH = 600; // Max total width of quick open widget

View File

@@ -114,7 +114,7 @@ class ListElementRenderer implements IListRenderer<ListElement, IListElementTemp
const row2 = dom.append(rows, $('.quick-input-list-row'));
// Label
data.label = new IconLabel(row1, { supportHighlights: true, supportDescriptionHighlights: true });
data.label = new IconLabel(row1, { supportHighlights: true, supportDescriptionHighlights: true, supportOcticons: true });
// Detail
const detailContainer = dom.append(row2, $('.quick-input-list-label-meta'));

View File

@@ -61,7 +61,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
private static readonly MAX_SHORT_RESPONSE_TIME = 500;
private static readonly ID = 'workbench.component.quickopen';
_serviceBrand: ServiceIdentifier<any>;
_serviceBrand!: ServiceIdentifier<any>;
private readonly _onShow: Emitter<void> = this._register(new Emitter<void>());
readonly onShow: Event<void> = this._onShow.event;
@@ -861,4 +861,4 @@ export class RemoveFromEditorHistoryAction extends Action {
}
}
registerSingleton(IQuickOpenService, QuickOpenController, true);
registerSingleton(IQuickOpenService, QuickOpenController, true);

View File

@@ -31,10 +31,11 @@ import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/c
import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { LayoutPriority } from 'vs/base/browser/ui/grid/grid';
export class SidebarPart extends CompositePart<Viewlet> implements IViewletService {
_serviceBrand: ServiceIdentifier<any>;
_serviceBrand!: ServiceIdentifier<any>;
static readonly activeViewletSettingsKey = 'workbench.sidebar.activeviewletid';
@@ -45,6 +46,8 @@ export class SidebarPart extends CompositePart<Viewlet> implements IViewletServi
readonly minimumHeight: number = 0;
readonly maximumHeight: number = Number.POSITIVE_INFINITY;
readonly priority: LayoutPriority = LayoutPriority.Low;
readonly snap = true;
get preferredWidth(): number | undefined {
@@ -79,7 +82,7 @@ export class SidebarPart extends CompositePart<Viewlet> implements IViewletServi
private viewletRegistry: ViewletRegistry;
private sideBarFocusContextKey: IContextKey<boolean>;
private activeViewletContextKey: IContextKey<string>;
private blockOpeningViewlet: boolean;
private blockOpeningViewlet = false;
constructor(
@INotificationService notificationService: INotificationService,

View File

@@ -323,7 +323,7 @@ class HideStatusbarEntryAction extends Action {
export class StatusbarPart extends Part implements IStatusbarService {
_serviceBrand: ServiceIdentifier<IStatusbarService>;
_serviceBrand!: ServiceIdentifier<IStatusbarService>;
//#region IView

View File

@@ -58,7 +58,7 @@ export class TitlebarPart extends Part implements ITitleService {
private _onMenubarVisibilityChange = this._register(new Emitter<boolean>());
readonly onMenubarVisibilityChange: Event<boolean> = this._onMenubarVisibilityChange.event;
_serviceBrand: ServiceIdentifier<any>;
_serviceBrand!: ServiceIdentifier<any>;
private title: HTMLElement;
private dragRegion: HTMLElement;
@@ -639,4 +639,4 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
}
});
registerSingleton(ITitleService, TitlebarPart);
registerSingleton(ITitleService, TitlebarPart);

View File

@@ -5,7 +5,7 @@
import 'vs/css!./media/views';
import { Event, Emitter } from 'vs/base/common/event';
import { IDisposable, Disposable, toDisposable, DisposableStore, MutableDisposable } from 'vs/base/common/lifecycle';
import { IDisposable, Disposable, toDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IAction, IActionViewItem, ActionRunner, Action } from 'vs/base/common/actions';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
@@ -33,18 +33,14 @@ import { ViewletPanel, IViewletPanelOptions } from 'vs/workbench/browser/parts/v
import { localize } from 'vs/nls';
import { timeout } from 'vs/base/common/async';
import { editorFindMatchHighlight, editorFindMatchHighlightBorder, textLinkForeground, textCodeBlockBackground, focusBorder } from 'vs/platform/theme/common/colorRegistry';
import { IMarkdownString } from 'vs/base/common/htmlContent';
import { isString } from 'vs/base/common/types';
import { renderMarkdown, RenderOptions } from 'vs/base/browser/htmlContentRenderer';
import { onUnexpectedError } from 'vs/base/common/errors';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IMarkdownRenderResult } from 'vs/editor/contrib/markdown/markdownRenderer';
import { ILabelService } from 'vs/platform/label/common/label';
import { Registry } from 'vs/platform/registry/common/platform';
import { IListVirtualDelegate, IIdentityProvider } from 'vs/base/browser/ui/list/list';
import { ITreeRenderer, ITreeNode, IAsyncDataSource, ITreeContextMenuEvent } from 'vs/base/browser/ui/tree/tree';
import { FuzzyScore, createMatches } from 'vs/base/common/filters';
import { CollapseAllAction } from 'vs/base/browser/ui/tree/treeDefaults';
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
export class CustomTreeViewPanel extends ViewletPanel {
@@ -167,7 +163,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
private focused: boolean = false;
private domNode: HTMLElement;
private treeContainer: HTMLElement;
private _messageValue: string | IMarkdownString | undefined;
private _messageValue: string | undefined;
private messageElement: HTMLDivElement;
private tree: WorkbenchAsyncDataTree<ITreeItem, ITreeItem, FuzzyScore>;
private treeLabels: ResourceLabels;
@@ -175,9 +171,6 @@ export class CustomTreeView extends Disposable implements ITreeView {
private elementsToRefresh: ITreeItem[] = [];
private menus: TitleMenus;
private markdownRenderer: MarkdownRenderer;
private markdownResult: IMarkdownRenderResult | null;
private readonly _onDidExpandItem: Emitter<ITreeItem> = this._register(new Emitter<ITreeItem>());
readonly onDidExpandItem: Event<ITreeItem> = this._onDidExpandItem.event;
@@ -217,12 +210,6 @@ export class CustomTreeView extends Disposable implements ITreeView {
this.doRefresh([this.root]); /** soft refresh **/
}
}));
this.markdownRenderer = instantiationService.createInstance(MarkdownRenderer);
this._register(toDisposable(() => {
if (this.markdownResult) {
this.markdownResult.dispose();
}
}));
this._register(Registry.as<IViewsRegistry>(Extensions.ViewsRegistry).onDidChangeContainer(({ views, from, to }) => {
if (from === this.viewContainer && views.some(v => v.id === this.id)) {
this.viewContainer = to;
@@ -256,12 +243,12 @@ export class CustomTreeView extends Disposable implements ITreeView {
}
}
private _message: string | IMarkdownString | undefined;
get message(): string | IMarkdownString | undefined {
private _message: string | undefined;
get message(): string | undefined {
return this._message;
}
set message(message: string | IMarkdownString | undefined) {
set message(message: string | undefined) {
this._message = message;
this.updateMessage();
}
@@ -470,16 +457,13 @@ export class CustomTreeView extends Disposable implements ITreeView {
this.updateContentAreas();
}
private showMessage(message: string | IMarkdownString): void {
private showMessage(message: string): void {
DOM.removeClass(this.messageElement, 'hide');
if (this._messageValue !== message) {
this.resetMessageElement();
this._messageValue = message;
if (isString(this._messageValue)) {
if (!isFalsyOrWhitespace(this._message)) {
this.messageElement.textContent = this._messageValue;
} else {
this.markdownResult = this.markdownRenderer.render(this._messageValue);
DOM.append(this.messageElement, this.markdownResult.element);
}
this.layout(this._height, this._width);
}
@@ -492,10 +476,6 @@ export class CustomTreeView extends Disposable implements ITreeView {
}
private resetMessageElement(): void {
if (this.markdownResult) {
this.markdownResult.dispose();
this.markdownResult = null;
}
DOM.clearNode(this.messageElement);
}
@@ -597,8 +577,16 @@ export class CustomTreeView extends Disposable implements ITreeView {
private async doRefresh(elements: ITreeItem[]): Promise<void> {
if (this.tree) {
this.refreshing = true;
await Promise.all(elements.map(element => this.tree.updateChildren(element, true)));
elements.map(element => this.tree.rerender(element));
const parents: Set<ITreeItem> = new Set<ITreeItem>();
elements.forEach(element => {
if (element !== this.root) {
const parent = this.tree.getParentElement(element);
parents.add(parent);
} else {
parents.add(element);
}
});
await Promise.all(Array.from(parents.values()).map(element => this.tree.updateChildren(element, true)));
this.refreshing = false;
this.updateContentAreas();
if (this.focused) {
@@ -718,7 +706,7 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
const icon = DOM.append(container, DOM.$('.custom-view-tree-node-item-icon'));
const resourceLabel = this.labels.create(container, { supportHighlights: true, donotSupportOcticons: true });
const resourceLabel = this.labels.create(container, { supportHighlights: true });
const actionsContainer = DOM.append(resourceLabel.element, DOM.$('.actions'));
const actionBar = new ActionBar(actionsContainer, {
actionViewItemProvider: this.actionViewItemProvider
@@ -885,38 +873,3 @@ class TreeMenus extends Disposable implements IDisposable {
}
}
class MarkdownRenderer {
constructor(
@IOpenerService private readonly _openerService: IOpenerService
) {
}
private getOptions(disposeables: DisposableStore): RenderOptions {
return {
actionHandler: {
callback: (content) => {
let uri: URI | undefined;
try {
uri = URI.parse(content);
} catch {
// ignore
}
if (uri && this._openerService) {
this._openerService.open(uri).catch(onUnexpectedError);
}
},
disposeables
}
};
}
render(markdown: IMarkdownString): IMarkdownRenderResult {
const disposeables = new DisposableStore();
const element: HTMLElement = markdown ? renderMarkdown(markdown, this.getOptions(disposeables)) : document.createElement('span');
return {
element,
dispose: () => disposeables.dispose()
};
}
}

View File

@@ -626,7 +626,7 @@ export class PersistentContributableViewsModel extends ContributableViewsModel {
export class ViewsService extends Disposable implements IViewsService {
_serviceBrand: ServiceIdentifier<any>;
_serviceBrand!: ServiceIdentifier<any>;
private readonly viewDescriptorCollections: Map<ViewContainer, { viewDescriptorCollection: IViewDescriptorCollection, disposable: IDisposable }>;
private readonly viewDisposable: Map<IViewDescriptor, IDisposable>;