提交 7b45f268 编写于 作者: B Benjamin Pasero

debt - use SyncDescriptor for editor part

上级 003ff303
......@@ -16,7 +16,6 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { WorkbenchState, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { EditorGroupsServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
import { SidebarVisibleContext, SideBarVisibleContext } from 'vs/workbench/common/viewlet';
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
......@@ -49,7 +48,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
@IEnvironmentService private environmentService: IEnvironmentService,
@IWindowService private windowService: IWindowService,
@IEditorService private editorService: IEditorService,
@IEditorGroupsService private editorGroupService: EditorGroupsServiceImpl,
@IEditorGroupsService private editorGroupService: IEditorGroupsService,
@IWorkbenchLayoutService private layoutService: IWorkbenchLayoutService,
@IViewletService private viewletService: IViewletService
) {
......
......@@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { GroupIdentifier, IWorkbenchEditorConfiguration, IWorkbenchEditorPartConfiguration, EditorOptions, TextEditorOptions, IEditorInput, IEditorIdentifier, IEditorCloseEvent, IEditor } from 'vs/workbench/common/editor';
import { GroupIdentifier, IWorkbenchEditorConfiguration, EditorOptions, TextEditorOptions, IEditorInput, IEditorIdentifier, IEditorCloseEvent, IEditor, IEditorPartOptions } from 'vs/workbench/common/editor';
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
import { IEditorGroup, GroupDirection, IAddGroupOptions, IMergeGroupOptions, GroupsOrder, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorGroup, GroupDirection, IAddGroupOptions, IMergeGroupOptions, GroupsOrder } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Dimension } from 'vs/base/browser/dom';
import { Event } from 'vs/base/common/event';
......@@ -21,10 +21,6 @@ export const EDITOR_TITLE_HEIGHT = 35;
export const DEFAULT_EDITOR_MIN_DIMENSIONS = new Dimension(220, 70);
export const DEFAULT_EDITOR_MAX_DIMENSIONS = new Dimension(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
export interface IEditorPartOptions extends IWorkbenchEditorPartConfiguration {
iconTheme?: string;
}
export const DEFAULT_EDITOR_PART_OPTIONS: IEditorPartOptions = {
showTabs: true,
highlightModifiedTabs: false,
......@@ -146,15 +142,3 @@ export interface EditorServiceImpl extends IEditorService {
*/
readonly onDidOpenEditorFail: Event<IEditorIdentifier>;
}
/**
* A sub-interface of IEditorGroupsService to hide some workbench-core specific
* methods from clients.
*/
export interface EditorGroupsServiceImpl extends IEditorGroupsService {
/**
* A promise that resolves when groups have been restored.
*/
readonly whenRestored: Promise<void>;
}
......@@ -9,14 +9,14 @@ import { Part } from 'vs/workbench/browser/part';
import { Dimension, isAncestor, toggleClass, addClass, $ } from 'vs/base/browser/dom';
import { Event, Emitter, Relay } from 'vs/base/common/event';
import { contrastBorder, editorBackground } from 'vs/platform/theme/common/colorRegistry';
import { GroupDirection, IAddGroupOptions, GroupsArrangement, GroupOrientation, IMergeGroupOptions, MergeGroupMode, ICopyEditorOptions, GroupsOrder, GroupChangeKind, GroupLocation, IFindGroupScope, EditorGroupLayout, GroupLayoutArgument } from 'vs/workbench/services/editor/common/editorGroupsService';
import { GroupDirection, IAddGroupOptions, GroupsArrangement, GroupOrientation, IMergeGroupOptions, MergeGroupMode, ICopyEditorOptions, GroupsOrder, GroupChangeKind, GroupLocation, IFindGroupScope, EditorGroupLayout, GroupLayoutArgument, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IInstantiationService, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { Direction, SerializableGrid, Sizing, ISerializedGrid, Orientation, GridBranchNode, isGridBranchNode, GridNode, createSerializedGrid, Grid } from 'vs/base/browser/ui/grid/grid';
import { GroupIdentifier, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor';
import { GroupIdentifier, IWorkbenchEditorConfiguration, IEditorPartOptions } from 'vs/workbench/common/editor';
import { values } from 'vs/base/common/map';
import { EDITOR_GROUP_BORDER, EDITOR_PANE_BACKGROUND } from 'vs/workbench/common/theme';
import { distinct } from 'vs/base/common/arrays';
import { IEditorGroupsAccessor, IEditorGroupView, IEditorPartOptions, getEditorPartOptions, impactsEditorPartOptions, IEditorPartOptionsChangeEvent, EditorGroupsServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorGroupsAccessor, IEditorGroupView, getEditorPartOptions, impactsEditorPartOptions, IEditorPartOptionsChangeEvent } from 'vs/workbench/browser/parts/editor/editor';
import { EditorGroupView } from 'vs/workbench/browser/parts/editor/editorGroupView';
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
import { IDisposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
......@@ -29,7 +29,7 @@ import { Color } from 'vs/base/common/color';
import { CenteredViewLayout } from 'vs/base/browser/ui/centered/centeredViewLayout';
import { IView, orthogonal, LayoutPriority } from 'vs/base/browser/ui/grid/gridview';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Parts } from 'vs/workbench/services/layout/browser/layoutService';
import { Parts, IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
interface IEditorPartUIState {
serializedGrid: ISerializedGrid;
......@@ -79,7 +79,7 @@ class GridWidgetView<T extends IView> implements IView {
}
}
export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditorGroupsAccessor {
export class EditorPart extends Part implements IEditorGroupsService, IEditorGroupsAccessor {
_serviceBrand: ServiceIdentifier<any>;
......@@ -140,7 +140,8 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IThemeService themeService: IThemeService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IStorageService storageService: IStorageService
@IStorageService storageService: IStorageService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService
) {
super(Parts.EDITOR_PART, { hasTitle: false }, themeService, storageService);
......@@ -153,6 +154,8 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
this._whenRestored = new Promise(resolve => (this.whenRestoredResolve = resolve));
layoutService.registerPart(this);
this.registerListeners();
}
......
......@@ -4,13 +4,13 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/notabstitlecontrol';
import { toResource, Verbosity, IEditorInput } from 'vs/workbench/common/editor';
import { toResource, Verbosity, IEditorInput, IEditorPartOptions } from 'vs/workbench/common/editor';
import { TitleControl, IToolbarActions } from 'vs/workbench/browser/parts/editor/titleControl';
import { ResourceLabel, IResourceLabel } from 'vs/workbench/browser/labels';
import { TAB_ACTIVE_FOREGROUND, TAB_UNFOCUSED_ACTIVE_FOREGROUND } from 'vs/workbench/common/theme';
import { EventType as TouchEventType, GestureEvent, Gesture } from 'vs/base/browser/touch';
import { addDisposableListener, EventType, addClass, EventHelper, removeClass, toggleClass } from 'vs/base/browser/dom';
import { IEditorPartOptions, EDITOR_TITLE_HEIGHT } from 'vs/workbench/browser/parts/editor/editor';
import { EDITOR_TITLE_HEIGHT } from 'vs/workbench/browser/parts/editor/editor';
import { IAction } from 'vs/base/common/actions';
import { CLOSE_EDITOR_COMMAND_ID } from 'vs/workbench/browser/parts/editor/editorCommands';
import { Color } from 'vs/base/common/color';
......
......@@ -6,7 +6,7 @@
import 'vs/css!./media/tabstitlecontrol';
import { isMacintosh } from 'vs/base/common/platform';
import { shorten } from 'vs/base/common/labels';
import { toResource, GroupIdentifier, IEditorInput, Verbosity, EditorCommandsContextActionRunner } from 'vs/workbench/common/editor';
import { toResource, GroupIdentifier, IEditorInput, Verbosity, EditorCommandsContextActionRunner, IEditorPartOptions } from 'vs/workbench/common/editor';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { EventType as TouchEventType, GestureEvent, Gesture } from 'vs/base/browser/touch';
import { KeyCode } from 'vs/base/common/keyCodes';
......@@ -35,7 +35,7 @@ import { MergeGroupMode, IMergeGroupOptions } from 'vs/workbench/services/editor
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { addClass, addDisposableListener, hasClass, EventType, EventHelper, removeClass, Dimension, scheduleAtNextAnimationFrame, findParentWithClass, clearNode } from 'vs/base/browser/dom';
import { localize } from 'vs/nls';
import { IEditorGroupsAccessor, IEditorPartOptions, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorGroupsAccessor, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
import { CloseOneEditorAction } from 'vs/workbench/browser/parts/editor/editorActions';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { BreadcrumbsControl } from 'vs/workbench/browser/parts/editor/breadcrumbsControl';
......
......@@ -32,8 +32,8 @@ import { DraggedEditorGroupIdentifier, DraggedEditorIdentifier, fillResourceData
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { BreadcrumbsConfig } from 'vs/workbench/browser/parts/editor/breadcrumbs';
import { BreadcrumbsControl, IBreadcrumbsControlOptions } from 'vs/workbench/browser/parts/editor/breadcrumbsControl';
import { EDITOR_TITLE_HEIGHT, IEditorGroupsAccessor, IEditorGroupView, IEditorPartOptions } from 'vs/workbench/browser/parts/editor/editor';
import { EditorCommandsContextActionRunner, IEditorCommandsContext, IEditorInput, toResource } from 'vs/workbench/common/editor';
import { EDITOR_TITLE_HEIGHT, IEditorGroupsAccessor, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
import { EditorCommandsContextActionRunner, IEditorCommandsContext, IEditorInput, toResource, IEditorPartOptions } from 'vs/workbench/common/editor';
import { ResourceContextKey } from 'vs/workbench/common/resources';
import { Themable } from 'vs/workbench/common/theme';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
......
......@@ -950,12 +950,12 @@ export type GroupIdentifier = number;
export interface IWorkbenchEditorConfiguration {
workbench: {
editor: IWorkbenchEditorPartConfiguration,
editor: IEditorPartConfiguration,
iconTheme: string;
};
}
export interface IWorkbenchEditorPartConfiguration {
interface IEditorPartConfiguration {
showTabs?: boolean;
highlightModifiedTabs?: boolean;
tabCloseButton?: 'left' | 'right' | 'off';
......@@ -974,6 +974,10 @@ export interface IWorkbenchEditorPartConfiguration {
restoreViewState?: boolean;
}
export interface IEditorPartOptions extends IEditorPartConfiguration {
iconTheme?: string;
}
export interface IResourceOptions {
supportSideBySide?: boolean;
filter?: string | string[];
......
......@@ -169,9 +169,6 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
private restored: boolean;
private disposed: boolean;
private editorService: EditorService;
private editorGroupService: IEditorGroupsService;
private instantiationService: IInstantiationService;
private contextService: IWorkspaceContextService;
private storageService: IStorageService;
......@@ -185,7 +182,6 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
private activitybarPart: ActivitybarPart;
private sidebarPart: SidebarPart;
private panelPart: PanelPart;
private editorPart: EditorPart;
private statusbarPart: StatusbarPart;
constructor(
......@@ -321,7 +317,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
this.layout();
// Restore
return this.restoreWorkbench();
return this.instantiationService.invokeFunction(accessor => this.restoreWorkbench(accessor));
}
private createWorkbenchContainer(): void {
......@@ -469,11 +465,8 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
serviceCollection.set(IFileService, new SyncDescriptor(RemoteFileService));
// Editor and Group services
this.editorPart = this.instantiationService.createInstance(EditorPart, !this.hasInitialFilesToOpen());
this.editorGroupService = this.editorPart;
serviceCollection.set(IEditorGroupsService, this.editorPart); // TODO@Ben use SyncDescriptor
this.editorService = this.instantiationService.createInstance(EditorService);
serviceCollection.set(IEditorService, this.editorService); // TODO@Ben use SyncDescriptor
serviceCollection.set(IEditorGroupsService, new SyncDescriptor(EditorPart, [!this.hasInitialFilesToOpen()]));
serviceCollection.set(IEditorService, new SyncDescriptor(EditorService));
// Contributed services
const contributedServices = getServices();
......@@ -627,7 +620,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
private createEditorPart(): void {
const editorContainer = this.createPart(Parts.EDITOR_PART, 'main', 'editor');
this.editorPart.create(editorContainer);
this.parts.get(Parts.EDITOR_PART).create(editorContainer);
}
private createStatusbarPart(): void {
......@@ -676,12 +669,18 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
registerNotificationCommands(notificationsCenter, notificationsToasts);
}
private restoreWorkbench(): Promise<void> {
private restoreWorkbench(accessor: ServicesAccessor): Promise<void> {
const editorService = accessor.get(IEditorService);
const editorGroupService = accessor.get(IEditorGroupsService);
const viewletService = accessor.get(IViewletService);
const panelService = accessor.get(IPanelService);
const logService = accessor.get(ILogService);
const restorePromises: Promise<any>[] = [];
// Restore editors
mark('willRestoreEditors');
restorePromises.push(this.editorPart.whenRestored.then(() => {
restorePromises.push(editorGroupService.whenRestored.then(() => {
function openEditors(editors: IResourceEditor[], editorService: IEditorService) {
if (editors.length) {
......@@ -692,19 +691,19 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
}
if (Array.isArray(this.state.editor.editorsToOpen)) {
return openEditors(this.state.editor.editorsToOpen, this.editorService);
return openEditors(this.state.editor.editorsToOpen, editorService);
}
return this.state.editor.editorsToOpen.then(editors => openEditors(editors, this.editorService));
return this.state.editor.editorsToOpen.then(editors => openEditors(editors, editorService));
}).then(() => mark('didRestoreEditors')));
// Restore Sidebar
if (this.state.sideBar.viewletToRestore) {
mark('willRestoreViewlet');
restorePromises.push(this.sidebarPart.openViewlet(this.state.sideBar.viewletToRestore)
restorePromises.push(viewletService.openViewlet(this.state.sideBar.viewletToRestore)
.then(viewlet => {
if (!viewlet) {
return this.sidebarPart.openViewlet(this.sidebarPart.getDefaultViewletId()); // fallback to default viewlet as needed
return viewletService.openViewlet(viewletService.getDefaultViewletId()); // fallback to default viewlet as needed
}
return viewlet;
......@@ -715,7 +714,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
// Restore Panel
if (this.state.panel.panelToRestore) {
mark('willRestorePanel');
this.panelPart.openPanel(this.state.panel.panelToRestore);
panelService.openPanel(this.state.panel.panelToRestore);
mark('didRestorePanel');
}
......@@ -730,7 +729,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
}
// Emit a warning after 10s if restore does not complete
const restoreTimeoutHandle = setTimeout(() => this.logService.warn('Workbench did not finish loading in 10 seconds, that might be a problem that should be reported.'), 10000);
const restoreTimeoutHandle = setTimeout(() => logService.warn('Workbench did not finish loading in 10 seconds, that might be a problem that should be reported.'), 10000);
let error: Error;
return Promise.all(restorePromises)
......@@ -802,6 +801,8 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
private statusBarPartView: View;
private windowService: IWindowService;
private editorService: IEditorService;
private editorGroupService: IEditorGroupsService;
private readonly state = {
fullscreen: false,
......@@ -1002,6 +1003,8 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
const environmentService = accessor.get(IEnvironmentService);
this.windowService = accessor.get(IWindowService);
this.editorService = accessor.get(IEditorService);
this.editorGroupService = accessor.get(IEditorGroupsService);
// Fullscreen
this.state.fullscreen = isFullscreen();
......@@ -1177,7 +1180,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
case Parts.PANEL_PART:
return this.panelPart.getContainer();
case Parts.EDITOR_PART:
return this.editorPart.getContainer();
return this.parts.get(Parts.EDITOR_PART).getContainer();
case Parts.STATUSBAR_PART:
return this.statusbarPart.getContainer();
}
......@@ -1281,8 +1284,8 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
this.state.zenMode.transitionDisposeables.push(this.editorService.onDidVisibleEditorsChange(() => setLineNumbers('off')));
}
if (config.hideTabs && this.editorPart.partOptions.showTabs) {
this.state.zenMode.transitionDisposeables.push(this.editorPart.enforcePartOptions({ showTabs: false }));
if (config.hideTabs && this.editorGroupService.partOptions.showTabs) {
this.state.zenMode.transitionDisposeables.push(this.editorGroupService.enforcePartOptions({ showTabs: false }));
}
if (config.centerLayout) {
......@@ -1348,6 +1351,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
private createWorkbenchLayout(): void {
const titlePart = this.parts.get(Parts.TITLEBAR_PART);
const editorPart = this.parts.get(Parts.EDITOR_PART);
if (this.configurationService.getValue('workbench.useExperimentalGridLayout')) {
......@@ -1355,7 +1359,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
this.titleBarPartView = new View(titlePart);
this.sideBarPartView = new View(this.sidebarPart);
this.activityBarPartView = new View(this.activitybarPart);
this.editorPartView = new View(this.editorPart);
this.editorPartView = new View(editorPart);
this.panelPartView = new View(this.panelPart);
this.statusBarPartView = new View(this.statusbarPart);
......@@ -1370,7 +1374,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
{
titlebar: titlePart,
activitybar: this.activitybarPart,
editor: this.editorPart,
editor: editorPart,
sidebar: this.sidebarPart,
panel: this.panelPart,
statusbar: this.statusbarPart,
......@@ -1503,13 +1507,13 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
this.storageService.store(Storage.CENTERED_LAYOUT_ENABLED, active, StorageScope.WORKSPACE);
let smartActive = active;
if (this.editorPart.groups.length > 1 && this.configurationService.getValue('workbench.editor.centeredLayoutAutoResize')) {
if (this.editorGroupService.groups.length > 1 && this.configurationService.getValue('workbench.editor.centeredLayoutAutoResize')) {
smartActive = false; // Respect the auto resize setting - do not go into centered layout if there is more than 1 group.
}
// Enter Centered Editor Layout
if (this.editorPart.isLayoutCentered() !== smartActive) {
this.editorPart.centerLayout(smartActive);
if (this.editorGroupService.isLayoutCentered() !== smartActive) {
this.editorGroupService.centerLayout(smartActive);
if (!skipLayout) {
this.layout();
......
......@@ -24,7 +24,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { Disposable, IDisposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
import { coalesce } from 'vs/base/common/arrays';
import { isCodeEditor, isDiffEditor, ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
import { IEditorGroupView, IEditorOpeningEvent, EditorGroupsServiceImpl, EditorServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
import { IEditorGroupView, IEditorOpeningEvent, EditorServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
import { ILabelService } from 'vs/platform/label/common/label';
type ICachedEditorInput = ResourceEditorInput | IFileEditorInput | DataUriEditorInput;
......@@ -58,7 +58,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
private lastActiveGroupId: GroupIdentifier;
constructor(
@IEditorGroupsService private readonly editorGroupService: EditorGroupsServiceImpl,
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
@IUntitledEditorService private readonly untitledEditorService: IUntitledEditorService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@ILabelService private readonly labelService: ILabelService,
......@@ -605,7 +605,7 @@ export class DelegatingEditorService extends EditorService {
private editorOpenHandler: IEditorOpenHandler;
constructor(
@IEditorGroupsService editorGroupService: EditorGroupsServiceImpl,
@IEditorGroupsService editorGroupService: IEditorGroupsService,
@IUntitledEditorService untitledEditorService: IUntitledEditorService,
@IInstantiationService instantiationService: IInstantiationService,
@ILabelService labelService: ILabelService,
......
......@@ -5,11 +5,12 @@
import { Event } from 'vs/base/common/event';
import { createDecorator, ServiceIdentifier, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IEditorInput, IEditor, GroupIdentifier, IEditorInputWithOptions, CloseDirection } from 'vs/workbench/common/editor';
import { IEditorInput, IEditor, GroupIdentifier, IEditorInputWithOptions, CloseDirection, IEditorPartOptions } from 'vs/workbench/common/editor';
import { IEditorOptions, ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IActiveEditor } from 'vs/workbench/services/editor/common/editorService';
import { IDimension } from 'vs/editor/common/editorCommon';
import { IDisposable } from 'vs/base/common/lifecycle';
export const IEditorGroupsService = createDecorator<IEditorGroupsService>('editorGroupsService');
......@@ -196,6 +197,11 @@ export interface IEditorGroupsService {
*/
readonly orientation: GroupOrientation;
/**
* A promise that resolves when groups have been restored.
*/
readonly whenRestored: Promise<void>;
/**
* Get all groups that are currently visible in the editor area optionally
* sorted by being most recent active or grid order. Will sort by creation
......@@ -233,6 +239,16 @@ export interface IEditorGroupsService {
*/
applyLayout(layout: EditorGroupLayout): void;
/**
* Enable or disable centered editor layout.
*/
centerLayout(active: boolean): void;
/**
* Find out if the editor layout is currently centered.
*/
isLayoutCentered(): boolean;
/**
* Sets the orientation of the root group to be either vertical or horizontal.
*/
......@@ -301,6 +317,16 @@ export interface IEditorGroupsService {
* @param direction the direction of where to split to
*/
copyGroup(group: IEditorGroup | GroupIdentifier, location: IEditorGroup | GroupIdentifier, direction: GroupDirection): IEditorGroup;
/**
* Access the options of the editor part.
*/
readonly partOptions: IEditorPartOptions;
/**
* Enforce editor part options temporarily.
*/
enforcePartOptions(options: IEditorPartOptions): IDisposable;
}
export const enum GroupChangeKind {
......
......@@ -8,8 +8,7 @@ import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart';
import { workbenchInstantiationService, TestStorageService } from 'vs/workbench/test/workbenchTestServices';
import { GroupDirection, GroupsOrder, MergeGroupMode, GroupOrientation, GroupChangeKind, EditorsOrder, GroupLocation } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IEditorPartOptions } from 'vs/workbench/browser/parts/editor/editor';
import { EditorInput, IFileEditorInput, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorExtensions, EditorOptions, CloseDirection } from 'vs/workbench/common/editor';
import { EditorInput, IFileEditorInput, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorExtensions, EditorOptions, CloseDirection, IEditorPartOptions } from 'vs/workbench/common/editor';
import { IEditorModel } from 'vs/platform/editor/common/editor';
import { URI } from 'vs/base/common/uri';
import { Registry } from 'vs/platform/registry/common/platform';
......
......@@ -11,12 +11,9 @@ import { append, $, hide } from 'vs/base/browser/dom';
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
import { StorageScope } from 'vs/platform/storage/common/storage';
import { Orientation } from 'vs/base/browser/ui/grid/grid';
import { Event } from 'vs/base/common/event';
class SimplePart extends Part {
onDidChange = Event.None;
element: HTMLElement;
minimumWidth: number;
maximumWidth: number;
minimumHeight: number;
......
......@@ -11,8 +11,8 @@ import * as resources from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { ConfirmResult, IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent } from 'vs/workbench/common/editor';
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView, EditorGroupsServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
import { ConfirmResult, IEditorInputWithOptions, CloseDirection, IEditorIdentifier, IUntitledResourceInput, IResourceDiffInput, IResourceSideBySideInput, IEditorInput, IEditor, IEditorCloseEvent, IEditorPartOptions } from 'vs/workbench/common/editor';
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
import { Event, Emitter } from 'vs/base/common/event';
import Severity from 'vs/base/common/severity';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
......@@ -549,7 +549,8 @@ export class TestLayoutService implements IWorkbenchLayoutService {
export class TestStorageService extends InMemoryStorageService { }
export class TestEditorGroupsService implements EditorGroupsServiceImpl {
export class TestEditorGroupsService implements IEditorGroupsService {
_serviceBrand: ServiceIdentifier<any>;
constructor(public groups: TestEditorGroup[] = []) { }
......@@ -627,6 +628,17 @@ export class TestEditorGroupsService implements EditorGroupsServiceImpl {
copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup {
throw new Error('not implemented');
}
centerLayout(active: boolean): void { }
isLayoutCentered(): boolean {
return false;
}
partOptions: IEditorPartOptions;
enforcePartOptions(options: IEditorPartOptions): IDisposable {
return Disposable.None;
}
}
export class TestEditorGroup implements IEditorGroupView {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册