提交 78783be3 编写于 作者: B Benjamin Pasero

grid - more service adoption

上级 14aea850
......@@ -29,7 +29,7 @@ import { forEach } from 'vs/base/common/collections';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
export interface IUserFriendlyViewsContainerDescriptor {
id: string;
......@@ -184,9 +184,9 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution {
constructor(
id: string, label: string,
@IViewletService viewletService: IViewletService,
@INextEditorService editorService: INextEditorService
@INextEditorGroupsService editorGroupService: INextEditorGroupsService
) {
super(id, label, id, viewletService, editorService);
super(id, label, id, viewletService, editorGroupService);
}
}
const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
......
......@@ -315,16 +315,13 @@ export class FocusActiveGroupAction extends Action {
constructor(
id: string,
label: string,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
@INextEditorGroupsService private editorGroupService: INextEditorGroupsService
) {
super(id, label);
}
public run(): TPromise<any> {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor) {
activeEditor.focus();
}
this.editorGroupService.activeGroup.focus();
return TPromise.as(true);
}
......@@ -699,24 +696,25 @@ export class RevertAndCloseEditorAction extends Action {
constructor(
id: string,
label: string,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@INextEditorGroupsService private editorGroupService: INextEditorGroupsService
) {
super(id, label);
}
public run(): TPromise<any> {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && activeEditor.input) {
const input = activeEditor.input;
const position = activeEditor.group;
const activeControl = this.editorService.activeControl;
if (activeControl && activeControl.input) {
const editor = activeControl.input;
const group = this.editorGroupService.getGroup(activeControl.group);
// first try a normal revert where the contents of the editor are restored
return activeEditor.input.revert().then(() => this.editorService.closeEditor(position, input), error => {
return editor.revert().then(() => group.closeEditor(editor), error => {
// if that fails, since we are about to close the editor, we accept that
// the editor cannot be reverted and instead do a soft revert that just
// enables us to close the editor. With this, a user can always close a
// dirty editor even when reverting fails.
return activeEditor.input.revert({ soft: true }).then(() => this.editorService.closeEditor(position, input));
return editor.revert({ soft: true }).then(() => group.closeEditor(editor));
});
}
......@@ -732,22 +730,31 @@ export class CloseLeftEditorsInGroupAction extends Action {
constructor(
id: string,
label: string,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IEditorGroupService private groupService: IEditorGroupService
@INextEditorService private editorService: INextEditorService,
@INextEditorGroupsService private groupService: INextEditorGroupsService
) {
super(id, label);
}
public run(context?: IEditorIdentifier): TPromise<any> {
const editor = getTarget(this.editorService, this.groupService, context);
if (editor) {
return this.editorService.closeEditors(editor.position, { except: editor.input, direction: CloseDirection.LEFT });
const { group, editor } = getTarget(this.editorService, this.groupService, context);
if (group && editor) {
return group.closeEditors({ direction: CloseDirection.LEFT, except: editor });
}
return TPromise.as(false);
}
}
function getTarget(editorService: INextEditorService, editorGroupService: INextEditorGroupsService, context?: IEditorIdentifier): { editor: IEditorInput, group: INextEditorGroup } {
if (context) {
return { editor: context.editor, group: editorGroupService.getGroup(context.groupId) };
}
// Fallback to active group
return { group: editorGroupService.activeGroup, editor: editorGroupService.activeGroup.activeEditor };
}
export class CloseAllEditorsAction extends Action {
public static readonly ID = 'workbench.action.closeAllEditors';
......@@ -952,19 +959,6 @@ export class MaximizeGroupAction extends Action {
}
}
function getTarget(editorService: IWorkbenchEditorService, editorGroupService: IEditorGroupService, context?: IEditorIdentifier): { input: IEditorInput, position: Position } {
if (context) {
return { input: context.editor, position: editorGroupService.getStacksModel().positionOfGroup(editorGroupService.getStacksModel().getGroup(context.groupId)) };
}
const activeEditor = editorService.getActiveEditor();
if (activeEditor) {
return { input: activeEditor.input, position: activeEditor.group };
}
return null;
}
export abstract class BaseNavigateEditorAction extends Action {
constructor(
......@@ -1380,18 +1374,16 @@ export class FocusLastEditorInStackAction extends Action {
constructor(
id: string,
label: string,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
@INextEditorGroupsService private editorGroupService: INextEditorGroupsService,
@INextEditorService private editorService: INextEditorService
) {
super(id, label);
}
public run(): TPromise<any> {
const active = this.editorService.getActiveEditor();
if (active) {
const group = this.editorGroupService.getStacksModel().groupAt(active.group);
const editor = group.getEditor(group.count - 1);
const activeGroup = this.editorGroupService.activeGroup;
if (activeGroup) {
const editor = activeGroup.getEditor(activeGroup.count - 1);
if (editor) {
return this.editorService.openEditor(editor);
}
......
......@@ -18,7 +18,7 @@ import { NotificationsList } from 'vs/workbench/browser/parts/notifications/noti
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { addClass, removeClass, isAncestor, Dimension } from 'vs/base/browser/dom';
import { widgetShadow } from 'vs/platform/theme/common/colorRegistry';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { localize } from 'vs/nls';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { ClearAllNotificationsAction, HideNotificationsCenterAction, NotificationActionRunner } from 'vs/workbench/browser/parts/notifications/notificationsActions';
......@@ -45,7 +45,7 @@ export class NotificationsCenter extends Themable {
@IInstantiationService private instantiationService: IInstantiationService,
@IPartService private partService: IPartService,
@IContextKeyService contextKeyService: IContextKeyService,
@INextEditorService private editorService: INextEditorService,
@INextEditorGroupsService private editorGroupService: INextEditorGroupsService,
@IKeybindingService private keybindingService: IKeybindingService
) {
super(themeService);
......@@ -174,7 +174,7 @@ export class NotificationsCenter extends Themable {
return; // only if visible
}
let focusEditor = false;
let focusGroup = false;
// Update notifications list based on event
switch (e.kind) {
......@@ -185,7 +185,7 @@ export class NotificationsCenter extends Themable {
this.notificationsList.updateNotificationsList(e.index, 1, [e.item]);
break;
case NotificationChangeType.REMOVE:
focusEditor = isAncestor(document.activeElement, this.notificationsCenterContainer);
focusGroup = isAncestor(document.activeElement, this.notificationsCenterContainer);
this.notificationsList.updateNotificationsList(e.index, 1);
break;
}
......@@ -197,26 +197,19 @@ export class NotificationsCenter extends Themable {
if (this.model.notifications.length === 0) {
this.hide();
// Restore focus to editor if we had focus
if (focusEditor) {
this.focusEditor();
// Restore focus to editor group if we had focus
if (focusGroup) {
this.editorGroupService.activeGroup.focus();
}
}
}
private focusEditor(): void {
const activeControl = this.editorService.activeControl;
if (activeControl) {
activeControl.focus();
}
}
public hide(): void {
if (!this._isVisible || !this.notificationsCenterContainer) {
return; // already hidden
}
const focusEditor = isAncestor(document.activeElement, this.notificationsCenterContainer);
const focusGroup = isAncestor(document.activeElement, this.notificationsCenterContainer);
// Hide
this._isVisible = false;
......@@ -229,8 +222,9 @@ export class NotificationsCenter extends Themable {
// Event
this._onDidChangeVisibility.fire();
if (focusEditor) {
this.focusEditor();
// Restore focus to editor group if we had focus
if (focusGroup) {
this.editorGroupService.activeGroup.focus();
}
}
......
......@@ -16,7 +16,7 @@ import { IPartService, Parts } from 'vs/workbench/services/part/common/partServi
import { Themable, NOTIFICATIONS_TOAST_BORDER } from 'vs/workbench/common/theme';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { widgetShadow } from 'vs/platform/theme/common/colorRegistry';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { NotificationsToastsVisibleContext } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { localize } from 'vs/nls';
......@@ -64,7 +64,7 @@ export class NotificationsToasts extends Themable {
@IInstantiationService private instantiationService: IInstantiationService,
@IPartService private partService: IPartService,
@IThemeService themeService: IThemeService,
@INextEditorService private editorService: INextEditorService,
@INextEditorGroupsService private editorGroupService: INextEditorGroupsService,
@IContextKeyService contextKeyService: IContextKeyService,
@ILifecycleService private lifecycleService: ILifecycleService
) {
......@@ -219,11 +219,11 @@ export class NotificationsToasts extends Themable {
private removeToast(item: INotificationViewItem): void {
const notificationToast = this.mapNotificationToToast.get(item);
let focusEditor = false;
let focusGroup = false;
if (notificationToast) {
const toastHasDOMFocus = isAncestor(document.activeElement, notificationToast.container);
if (toastHasDOMFocus) {
focusEditor = !(this.focusNext() || this.focusPrevious()); // focus next if any, otherwise focus editor
focusGroup = !(this.focusNext() || this.focusPrevious()); // focus next if any, otherwise focus editor
}
// Listeners
......@@ -242,20 +242,13 @@ export class NotificationsToasts extends Themable {
else {
this.doHide();
// Move focus to editor as needed
if (focusEditor) {
this.focusEditor();
// Move focus back to editor group as needed
if (focusGroup) {
this.editorGroupService.activeGroup.focus();
}
}
}
private focusEditor(): void {
const activeControl = this.editorService.activeControl;
if (activeControl) {
activeControl.focus();
}
}
private removeToasts(): void {
this.mapNotificationToToast.forEach(toast => dispose(toast.disposeables));
this.mapNotificationToToast.clear();
......@@ -273,12 +266,12 @@ export class NotificationsToasts extends Themable {
}
public hide(): void {
const focusEditor = isAncestor(document.activeElement, this.notificationsToastsContainer);
const focusGroup = isAncestor(document.activeElement, this.notificationsToastsContainer);
this.removeToasts();
if (focusEditor) {
this.focusEditor();
if (focusGroup) {
this.editorGroupService.activeGroup.focus();
}
}
......
......@@ -33,7 +33,7 @@ import { Button } from 'vs/base/browser/ui/button/button';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { onUnexpectedError, canceled } from 'vs/base/common/errors';
import Severity from 'vs/base/common/severity';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { Action } from 'vs/base/common/actions';
......@@ -369,7 +369,7 @@ export class QuickInputService extends Component implements IQuickInputService {
@IInstantiationService private instantiationService: IInstantiationService,
@IPartService private partService: IPartService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@INextEditorService private editorService: INextEditorService,
@INextEditorGroupsService private editorGroupService: INextEditorGroupsService,
@IContextKeyService contextKeyService: IContextKeyService,
@IThemeService themeService: IThemeService
) {
......@@ -534,7 +534,7 @@ export class QuickInputService extends Component implements IQuickInputService {
this.inQuickOpen('quickInput', false);
this.ui.container.style.display = 'none';
if (!focusLost) {
this.restoreFocus();
this.editorGroupService.activeGroup.focus();
}
});
result.then(null, onUnexpectedError);
......@@ -544,18 +544,11 @@ export class QuickInputService extends Component implements IQuickInputService {
this.inQuickOpen('quickInput', false);
this.ui.container.style.display = 'none';
if (!focusLost) {
this.restoreFocus();
this.editorGroupService.activeGroup.focus();
}
return TPromise.as(undefined);
}
private restoreFocus(): void {
const activeControl = this.editorService.activeControl;
if (activeControl) {
activeControl.focus();
}
}
pick<T extends IPickOpenEntry, O extends IPickOptions>(picks: TPromise<T[]>, options: O = <O>{}, token?: CancellationToken): TPromise<O extends { canPickMany: true } ? T[] : T> {
return this._pick(undefined, picks, options, token);
}
......
......@@ -56,6 +56,7 @@ import Severity from 'vs/base/common/severity';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { Dimension, addClass } from 'vs/base/browser/dom';
import { INextEditorService, ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
const HELP_PREFIX = '?';
......@@ -101,6 +102,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
constructor(
@INextEditorService private editorService: INextEditorService,
@INextEditorGroupsService private editorGroupService: INextEditorGroupsService,
@INotificationService private notificationService: INotificationService,
@IContextKeyService private contextKeyService: IContextKeyService,
@IConfigurationService private configurationService: IConfigurationService,
......@@ -573,7 +575,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
}
if (reason !== HideReason.FOCUS_LOST) {
this.restoreFocus(); // focus back to editor unless user clicked somewhere else
this.editorGroupService.activeGroup.focus(); // focus back to editor group unless user clicked somewhere else
}
// Reset context keys
......@@ -623,15 +625,6 @@ export class QuickOpenController extends Component implements IQuickOpenService
return new QuickOpenModel(entries, this.actionProvider);
}
private restoreFocus(): void {
// Try to focus active editor
const editorControl = this.editorService.activeControl;
if (editorControl) {
editorControl.focus();
}
}
private onType(value: string): void {
// look for a handler
......
......@@ -17,7 +17,7 @@ import { ToggleSidebarVisibilityAction } from 'vs/workbench/browser/actions/togg
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
export abstract class Viewlet extends Composite implements IViewlet {
......@@ -120,12 +120,12 @@ export class ToggleViewletAction extends Action {
name: string,
viewletId: string,
@IViewletService protected viewletService: IViewletService,
@INextEditorService private editorService: INextEditorService
@INextEditorGroupsService private editorGroupService: INextEditorGroupsService
) {
super(id, name);
this.viewletId = viewletId;
this.enabled = !!this.viewletService && !!this.editorService;
this.enabled = !!this.viewletService && !!this.editorGroupService;
}
public run(): TPromise<any> {
......@@ -135,11 +135,8 @@ export class ToggleViewletAction extends Action {
return this.viewletService.openViewlet(this.viewletId, true);
}
// Otherwise pass focus to editor if possible
const editor = this.editorService.activeControl;
if (editor) {
editor.focus();
}
// Otherwise pass focus to editor group
this.editorGroupService.activeGroup.focus();
return TPromise.as(true);
}
......
......@@ -14,7 +14,7 @@ import { IWindowsService, IWindowService } from 'vs/platform/windows/common/wind
import { List } from 'vs/base/browser/ui/list/listWidget';
import * as errors from 'vs/base/common/errors';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import URI from 'vs/base/common/uri';
import { IEditorOptions, Position as EditorPosition } from 'vs/platform/editor/common/editor';
import { WorkbenchListFocusContextKey, IListService, WorkbenchListSupportsMultiSelectContextKey, ListWidget } from 'vs/platform/list/browser/listService';
......@@ -536,7 +536,7 @@ export function registerCommands(): void {
});
CommandsRegistry.registerCommand('_workbench.diff', function (accessor: ServicesAccessor, args: [URI, URI, string, string, IEditorOptions, EditorPosition]) {
const editorService = accessor.get(IWorkbenchEditorService);
const editorService = accessor.get(INextEditorService);
let [leftResource, rightResource, label, description, options, position] = args;
if (!options || typeof options !== 'object') {
......@@ -555,7 +555,7 @@ export function registerCommands(): void {
});
CommandsRegistry.registerCommand('_workbench.open', function (accessor: ServicesAccessor, args: [URI, IEditorOptions, EditorPosition]) {
const editorService = accessor.get(IWorkbenchEditorService);
const editorService = accessor.get(INextEditorService);
const [resource, options, column] = args;
return editorService.openEditor({ resource, options }, column).then(() => {
......
......@@ -16,9 +16,8 @@ import * as DOM from 'vs/base/browser/dom';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IAction, Action } from 'vs/base/common/actions';
import { AutoSaveConfiguration, IFileService } from 'vs/platform/files/common/files';
import { toResource, IUntitledResourceInput, IEditor } from 'vs/workbench/common/editor';
import { IWorkbenchEditorService, IResourceInputType } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { toResource, IUntitledResourceInput } from 'vs/workbench/common/editor';
import { INextEditorService, IResourceEditor } from 'vs/workbench/services/editor/common/nextEditorService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { IWindowsService, IWindowService, IWindowSettings, IPath, IOpenFileRequest, IWindowsConfiguration, IAddFoldersRequest, IRunActionInWindowRequest } from 'vs/platform/windows/common/windows';
......@@ -29,7 +28,7 @@ import { IWorkbenchThemeService, VS_HC_THEME, VS_DARK_THEME } from 'vs/workbench
import * as browser from 'vs/base/browser/browser';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { Position, IResourceInput } from 'vs/platform/editor/common/editor';
import { IResourceInput } from 'vs/platform/editor/common/editor';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/keybindingService';
import { Themable } from 'vs/workbench/common/theme';
......@@ -75,8 +74,7 @@ export class ElectronWindow extends Themable {
constructor(
shellContainer: HTMLElement,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@INextEditorService private editorService: INextEditorService,
@IWindowsService private windowsService: IWindowsService,
@IWindowService private windowService: IWindowService,
@IWorkspaceConfigurationService private configurationService: IWorkspaceConfigurationService,
......@@ -113,10 +111,10 @@ export class ElectronWindow extends Themable {
private registerListeners(): void {
// React to editor input changes
this.toUnbind.push(this.editorGroupService.onEditorsChanged(() => {
this.toUnbind.push(this.editorService.onDidActiveEditorChange(() => {
// Represented File Name
const file = toResource(this.editorService.getActiveEditorInput(), { supportSideBySide: true, filter: 'file' });
const file = toResource(this.editorService.activeEditor, { supportSideBySide: true, filter: 'file' });
this.titleService.setRepresentedFilename(file ? file.fsPath : '');
// Touch Bar
......@@ -137,9 +135,9 @@ export class ElectronWindow extends Themable {
// If we run an action from the touchbar, we fill in the currently active resource
// as payload because the touch bar items are context aware depending on the editor
if (request.from === 'touchbar') {
const activeEditor = this.editorService.getActiveEditor();
const activeEditor = this.editorService.activeEditor;
if (activeEditor) {
const resource = toResource(activeEditor.input, { supportSideBySide: true });
const resource = toResource(activeEditor, { supportSideBySide: true });
if (resource) {
args.push(resource);
}
......@@ -358,7 +356,7 @@ export class ElectronWindow extends Themable {
this.touchBarDisposables = dispose(this.touchBarDisposables);
// Create new
this.touchBarMenu = this.editorGroupService.invokeWithinEditorContext(accessor => this.menuService.createMenu(MenuId.TouchBarContext, accessor.get(IContextKeyService)));
this.touchBarMenu = this.editorService.invokeWithinEditorContext(accessor => this.menuService.createMenu(MenuId.TouchBarContext, accessor.get(IContextKeyService)));
this.touchBarDisposables.push(this.touchBarMenu);
this.touchBarDisposables.push(this.touchBarMenu.onDidChange(() => {
this.scheduleSetupTouchbar();
......@@ -458,7 +456,7 @@ export class ElectronWindow extends Themable {
}
private onOpenFiles(request: IOpenFileRequest): void {
const inputs: IResourceInputType[] = [];
const inputs: IResourceEditor[] = [];
const diffMode = (request.filesToDiff.length === 2);
if (!diffMode && request.filesToOpen) {
......@@ -483,9 +481,8 @@ export class ElectronWindow extends Themable {
// the wait marker file to signal to the outside that editing is done.
const resourcesToWaitFor = request.filesToWait.paths.map(p => URI.file(p.filePath));
const waitMarkerFile = URI.file(request.filesToWait.waitMarkerFilePath);
const stacks = this.editorGroupService.getStacksModel();
const unbind = stacks.onEditorClosed(() => {
if (resourcesToWaitFor.every(r => !stacks.isOpen(r))) {
const unbind = this.editorService.onDidCloseEditor(() => {
if (resourcesToWaitFor.every(resource => !this.editorService.isOpen({ resource }))) {
unbind.dispose();
this.fileService.del(waitMarkerFile).done(null, errors.onUnexpectedError);
}
......@@ -493,8 +490,8 @@ export class ElectronWindow extends Themable {
}
}
private openResources(resources: (IResourceInput | IUntitledResourceInput)[], diffMode: boolean): Thenable<IEditor | IEditor[]> {
return this.lifecycleService.when(LifecyclePhase.Running).then((): TPromise<IEditor | IEditor[]> => {
private openResources(resources: (IResourceInput | IUntitledResourceInput)[], diffMode: boolean): Thenable<any> {
return this.lifecycleService.when(LifecyclePhase.Running).then((): TPromise<any> => {
// In diffMode we open 2 resources as diff
if (diffMode && resources.length === 2) {
......@@ -507,17 +504,11 @@ export class ElectronWindow extends Themable {
}
// Otherwise open all
const activeEditor = this.editorService.getActiveEditor();
return this.editorService.openEditors(resources.map((r, index) => {
return {
input: r,
position: activeEditor ? activeEditor.group : Position.ONE
};
}));
return this.editorService.openEditors(resources);
});
}
private toInputs(paths: IPath[], isNew: boolean): IResourceInputType[] {
private toInputs(paths: IPath[], isNew: boolean): IResourceEditor[] {
return paths.map(p => {
const resource = URI.file(p.filePath);
let input: IResourceInput | IUntitledResourceInput;
......
......@@ -191,7 +191,7 @@ export class Workbench extends Disposable implements IPartService {
private workbenchShutdown: boolean;
private editorService: NextEditorService;
private editorGroupsService: INextEditorGroupsService;
private editorGroupService: INextEditorGroupsService;
private viewletService: IViewletService;
private contextKeyService: IContextKeyService;
private keybindingService: IKeybindingService;
......@@ -382,7 +382,7 @@ export class Workbench extends Disposable implements IPartService {
const restorePreviousEditorState = !this.hasInitialFilesToOpen;
this.editorPart = this.instantiationService.createInstance(NextEditorPart, Identifiers.EDITOR_PART, restorePreviousEditorState);
this._register(toDisposable(() => this.editorPart.shutdown()));
this.editorGroupsService = this.editorPart;
this.editorGroupService = this.editorPart;
serviceCollection.set(INextEditorGroupsService, this.editorPart);
this.editorService = this.instantiationService.createInstance(NextEditorService);
serviceCollection.set(INextEditorService, this.editorService);
......@@ -598,19 +598,19 @@ export class Workbench extends Disposable implements IPartService {
activeEditorGroupEmpty.reset();
}
if (this.editorGroupsService.count > 1) {
if (this.editorGroupService.count > 1) {
multipleEditorGroups.set(true);
} else {
multipleEditorGroups.reset();
}
};
this.editorGroupsService.whenRestored.then(() => updateEditorContextKeys());
this.editorGroupService.whenRestored.then(() => updateEditorContextKeys());
this._register(this.editorService.onDidActiveEditorChange(() => updateEditorContextKeys()));
this._register(this.editorService.onDidVisibleEditorsChange(() => updateEditorContextKeys()));
this._register(this.editorGroupsService.onDidAddGroup(() => updateEditorContextKeys()));
this._register(this.editorGroupsService.onDidRemoveGroup(() => updateEditorContextKeys()));
this._register(this.editorGroupService.onDidAddGroup(() => updateEditorContextKeys()));
this._register(this.editorGroupService.onDidRemoveGroup(() => updateEditorContextKeys()));
const inputFocused = InputFocusedContext.bindTo(this.contextKeyService);
this._register(DOM.addDisposableListener(window, 'focusin', () => {
......@@ -635,7 +635,7 @@ export class Workbench extends Disposable implements IPartService {
// Restore Editorpart
perf.mark('willRestoreEditors');
restorePromises.push(this.editorGroupsService.whenRestored.then(() => {
restorePromises.push(this.editorGroupService.whenRestored.then(() => {
return this.resolveEditorsToOpen().then(inputs => {
if (inputs.length) {
return this.editorService.openEditors(inputs);
......@@ -739,7 +739,7 @@ export class Workbench extends Disposable implements IPartService {
// Empty workbench
else if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY && this.openUntitledFile()) {
const isEmpty = this.editorGroupsService.count === 1 && this.editorGroupsService.activeGroup.count === 0;
const isEmpty = this.editorGroupService.count === 1 && this.editorGroupService.activeGroup.count === 0;
if (!isEmpty) {
return TPromise.as([]); // do not open any empty untitled file if we restored editors from previous session
}
......@@ -1212,10 +1212,7 @@ export class Workbench extends Disposable implements IPartService {
// Status bar and activity bar visibility come from settings -> update their visibility.
this.onDidUpdateConfiguration(true);
const activeEditor = this.editorService.activeControl;
if (activeEditor) {
activeEditor.focus();
}
this.editorGroupService.activeGroup.focus();
toggleFullScreen = this.zenMode.transitionedToFullScreen && browser.isFullscreen();
}
......@@ -1250,19 +1247,19 @@ export class Workbench extends Disposable implements IPartService {
// Enter Centered Editor Layout
if (active) {
if (this.editorGroupsService.count === 1) {
const activeGroup = this.editorGroupsService.activeGroup;
this.editorGroupsService.addGroup(activeGroup, GroupDirection.LEFT);
this.editorGroupsService.addGroup(activeGroup, GroupDirection.RIGHT);
if (this.editorGroupService.count === 1) {
const activeGroup = this.editorGroupService.activeGroup;
this.editorGroupService.addGroup(activeGroup, GroupDirection.LEFT);
this.editorGroupService.addGroup(activeGroup, GroupDirection.RIGHT);
}
}
// Leave Centered Editor Layout
else {
if (this.editorGroupsService.count === 3) {
this.editorGroupsService.groups.forEach(group => {
if (this.editorGroupService.count === 3) {
this.editorGroupService.groups.forEach(group => {
if (group.count === 0) {
this.editorGroupsService.removeGroup(group);
this.editorGroupService.removeGroup(group);
}
});
}
......@@ -1309,14 +1306,13 @@ export class Workbench extends Disposable implements IPartService {
let promise = TPromise.wrap<any>(null);
if (hidden && this.sidebarPart.getActiveViewlet()) {
promise = this.sidebarPart.hideActiveViewlet().then(() => {
const activeEditor = this.editorService.activeControl;
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 if (activeEditor) {
activeEditor.focus();
} else {
this.editorGroupService.activeGroup.focus();
}
});
}
......@@ -1360,12 +1356,7 @@ export class Workbench extends Disposable implements IPartService {
let promise = TPromise.wrap<any>(null);
if (hidden && this.panelPart.getActivePanel()) {
promise = this.panelPart.hideActivePanel().then(() => {
// Pass Focus to Editor if Panel part is now hidden
const editor = this.editorService.activeControl;
if (editor) {
editor.focus();
}
this.editorGroupService.activeGroup.focus(); // Pass focus to editor group if panel part is now hidden
});
}
......
......@@ -50,7 +50,7 @@ import { DebugQuickOpenHandler } from 'vs/workbench/parts/debug/browser/debugQui
import { DebugStatus } from 'vs/workbench/parts/debug/browser/debugStatus';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { launchSchemaId } from 'vs/workbench/services/configuration/common/configuration';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
class OpenDebugViewletAction extends ToggleViewletAction {
public static readonly ID = VIEWLET_ID;
......@@ -60,9 +60,9 @@ class OpenDebugViewletAction extends ToggleViewletAction {
id: string,
label: string,
@IViewletService viewletService: IViewletService,
@INextEditorService editorService: INextEditorService
@INextEditorGroupsService editorGroupService: INextEditorGroupsService
) {
super(id, label, VIEWLET_ID, viewletService, editorService);
super(id, label, VIEWLET_ID, viewletService, editorGroupService);
}
}
......
......@@ -47,6 +47,7 @@ import { mnemonicButtonLabel } from 'vs/base/common/labels';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IQuickOpenService, IPickOpenEntry } from 'vs/platform/quickOpen/common/quickOpen';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
const promptDownloadManually = (extension: IExtension, message: string, instantiationService: IInstantiationService, notificationService: INotificationService, openerService: IOpenerService) => {
notificationService.prompt(Severity.Error, message, [{
......@@ -957,9 +958,9 @@ export class OpenExtensionsViewletAction extends ToggleViewletAction {
id: string,
label: string,
@IViewletService viewletService: IViewletService,
@INextEditorService editorService: INextEditorService
@INextEditorGroupsService editorGroupService: INextEditorGroupsService
) {
super(id, label, VIEWLET_ID, viewletService, editorService);
super(id, label, VIEWLET_ID, viewletService, editorGroupService);
}
}
......
......@@ -33,6 +33,7 @@ import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } fro
import { DataUriEditorInput } from 'vs/workbench/common/editor/dataUriEditorInput';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
// Viewlet Action
export class OpenExplorerViewletAction extends ToggleViewletAction {
......@@ -43,9 +44,9 @@ export class OpenExplorerViewletAction extends ToggleViewletAction {
id: string,
label: string,
@IViewletService viewletService: IViewletService,
@INextEditorService editorService: INextEditorService
@INextEditorGroupsService editorGroupService: INextEditorGroupsService
) {
super(id, label, VIEWLET_ID, viewletService, editorService);
super(id, label, VIEWLET_ID, viewletService, editorGroupService);
}
}
......
......@@ -19,15 +19,15 @@ import { StatusUpdater, StatusBarController } from './scmActivity';
import { SCMViewlet } from 'vs/workbench/parts/scm/electron-browser/scmViewlet';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
class OpenSCMViewletAction extends ToggleViewletAction {
static readonly ID = VIEWLET_ID;
static LABEL = localize('toggleGitViewlet', "Show Git");
constructor(id: string, label: string, @IViewletService viewletService: IViewletService, @INextEditorService editorService: INextEditorService) {
super(id, label, VIEWLET_ID, viewletService, editorService);
constructor(id: string, label: string, @IViewletService viewletService: IViewletService, @INextEditorGroupsService editorGroupService: INextEditorGroupsService) {
super(id, label, VIEWLET_ID, viewletService, editorGroupService);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册