提交 08f1beb9 编写于 作者: I isidor

bye bye old editorService and old groupService

上级 2571a957
......@@ -17,7 +17,6 @@ import { IPartService } from 'vs/workbench/services/part/common/partService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
......@@ -29,6 +28,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
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';
export interface IUserFriendlyViewsContainerDescriptor {
......@@ -158,7 +158,7 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution {
@ITelemetryService telemetryService: ITelemetryService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IStorageService storageService: IStorageService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
@INextEditorService editorService: INextEditorService,
@IInstantiationService instantiationService: IInstantiationService,
@IContextKeyService contextKeyService: IContextKeyService,
@IThemeService themeService: IThemeService,
......@@ -184,7 +184,7 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution {
constructor(
id: string, label: string,
@IViewletService viewletService: IViewletService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService
@INextEditorService editorService: INextEditorService
) {
super(id, label, id, viewletService, editorService);
}
......@@ -205,4 +205,4 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution {
}
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(ViewsContainersExtensionHandler, LifecyclePhase.Starting);
\ No newline at end of file
workbenchRegistry.registerWorkbenchContribution(ViewsContainersExtensionHandler, LifecyclePhase.Starting);
......@@ -300,7 +300,7 @@ function registerEditorCommands() {
const editorGroupService = accessor.get(IEditorGroupService);
const model = editorGroupService.getStacksModel();
const editorService = accessor.get(IWorkbenchEditorService);
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService), accessor.get(IEditorGroupService));
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService), accessor.get(INextEditorGroupsService));
if (contexts.length === 0 && model.activeGroup) {
// If command is triggered from the command palette use the active group
contexts.push({ groupId: model.activeGroup.id });
......@@ -329,7 +329,7 @@ function registerEditorCommands() {
handler: (accessor, resource: URI | object, context: IEditorCommandsContext) => {
const editorGroupService = accessor.get(IEditorGroupService);
const editorService = accessor.get(IWorkbenchEditorService);
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService), accessor.get(IEditorGroupService));
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService), accessor.get(INextEditorGroupsService));
const distinctGroupIds = distinct(contexts.map(c => c.groupId));
const model = editorGroupService.getStacksModel();
......@@ -356,7 +356,7 @@ function registerEditorCommands() {
const editorService = accessor.get(IWorkbenchEditorService);
const nextEditorGroupService = accessor.get(INextEditorGroupsService);
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService), accessor.get(IEditorGroupService));
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService), accessor.get(INextEditorGroupsService));
const groupIds = distinct(contexts.map(context => context.groupId));
const model = editorGroupService.getStacksModel();
......@@ -415,7 +415,7 @@ function registerEditorCommands() {
handler: (accessor, resource: URI | object, context: IEditorCommandsContext) => {
const editorGroupService = accessor.get(IEditorGroupService);
const editorService = accessor.get(IWorkbenchEditorService);
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService), accessor.get(IEditorGroupService));
const contexts = getMultiSelectedEditorContexts(context, accessor.get(IListService), accessor.get(INextEditorGroupsService));
const model = editorGroupService.getStacksModel();
if (contexts.length === 0) {
......@@ -547,13 +547,12 @@ function positionAndInput(editorGroupService: IEditorGroupService, editorService
return { position, input };
}
export function getMultiSelectedEditorContexts(editorContext: IEditorCommandsContext, listService: IListService, editorGroupService: IEditorGroupService): IEditorCommandsContext[] {
const stacks = editorGroupService.getStacksModel();
export function getMultiSelectedEditorContexts(editorContext: IEditorCommandsContext, listService: IListService, editorGroupService: INextEditorGroupsService): IEditorCommandsContext[] {
// First check for a focused list to return the selected items from
const list = listService.lastFocusedList;
if (list instanceof List && list.isDOMFocused()) {
const elementToContext = (element: IEditorIdentifier | EditorGroup) =>
element instanceof EditorGroup ? { groupId: element.id, editorIndex: undefined } : { groupId: element.group, editorIndex: stacks.getGroup(element.group).indexOf(element.editor) };
element instanceof EditorGroup ? { groupId: element.id, editorIndex: undefined } : { groupId: element.group, editorIndex: editorGroupService.getGroup(element.group).getIndexOfEditor(element.editor) };
const onlyEditorGroupAndEditor = (e: IEditorIdentifier | EditorGroup) => e instanceof EditorGroup || ('editor' in e && 'group' in e);
const focusedElements: (IEditorIdentifier | EditorGroup)[] = list.getFocusedElements().filter(onlyEditorGroupAndEditor);
......@@ -563,7 +562,7 @@ export function getMultiSelectedEditorContexts(editorContext: IEditorCommandsCon
if (focus) {
const selection: (IEditorIdentifier | EditorGroup)[] = list.getSelectedElements().filter(onlyEditorGroupAndEditor);
// Only respect selection if it contains focused element
if (selection && selection.some(s => s instanceof EditorGroup ? s.id === focus.groupId : s.group === focus.groupId && stacks.getGroup(s.group).indexOf(s.editor) === focus.editorIndex)) {
if (selection && selection.some(s => s instanceof EditorGroup ? s.id === focus.groupId : s.group === focus.groupId && editorGroupService.getGroup(s.group).getIndexOfEditor(s.editor) === focus.editorIndex)) {
return selection.map(elementToContext);
}
......
......@@ -28,9 +28,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { ScrollType, IDiffEditorViewState, IDiffEditorModel } from 'vs/editor/common/editorCommon';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
......@@ -63,13 +61,12 @@ export class TextDiffEditor extends BaseTextEditor {
@IStorageService storageService: IStorageService,
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
@IConfigurationService private readonly _actualConfigurationService: IConfigurationService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService editorService: INextEditorService,
@IThemeService themeService: IThemeService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@INextEditorGroupsService editorGroupService: INextEditorGroupsService,
@ITextFileService textFileService: ITextFileService,
@INextEditorGroupsService nextEditorGroupService: INextEditorGroupsService
) {
super(TextDiffEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorGroupService, nextEditorGroupService);
super(TextDiffEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService);
this.diffNavigatorDisposables = [];
this.toUnbind.push(this._actualConfigurationService.onDidChangeConfiguration((e) => {
......
......@@ -23,11 +23,11 @@ import { Scope } from 'vs/workbench/common/memento';
import { getCodeEditor, getCodeOrDiffEditor } from 'vs/editor/browser/services/codeEditorService';
import { ITextFileService, SaveReason, AutoSaveMode } from 'vs/workbench/services/textfile/common/textfiles';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { isDiffEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { CancellationToken } from 'vs/base/common/cancellation';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
const TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'textEditorViewState';
......@@ -55,12 +55,12 @@ export abstract class BaseTextEditor extends BaseEditor {
@ITextResourceConfigurationService private readonly _configurationService: ITextResourceConfigurationService,
@IThemeService protected themeService: IThemeService,
@ITextFileService private readonly _textFileService: ITextFileService,
@IEditorGroupService protected editorGroupService: IEditorGroupService,
@INextEditorGroupsService private nextEditorGroupService: INextEditorGroupsService
@INextEditorService protected editorService: INextEditorService,
@INextEditorGroupsService private editorGroupService: INextEditorGroupsService,
) {
super(id, telemetryService, themeService);
this.editorViewStateMemento = new EditorViewStateMemento<IEditorViewState>(nextEditorGroupService, this.getMemento(storageService, Scope.WORKSPACE), TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY, 100);
this.editorViewStateMemento = new EditorViewStateMemento<IEditorViewState>(editorGroupService, this.getMemento(storageService, Scope.WORKSPACE), TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY, 100);
this.toUnbind.push(this.configurationService.onDidChangeConfiguration(e => this.handleConfigurationChangeEvent(this.configurationService.getValue<IEditorConfiguration>(this.getResource()))));
}
......@@ -109,7 +109,7 @@ export abstract class BaseTextEditor extends BaseEditor {
// Apply group information to help identify in which group we are
if (ariaLabel) {
const group = this.nextEditorGroupService.getGroup(this.group);
const group = this.editorGroupService.getGroup(this.group);
if (group) {
ariaLabel = nls.localize('editorLabelWithGroup', "{0}, {1}.", ariaLabel, group.label);
}
......@@ -150,7 +150,7 @@ export abstract class BaseTextEditor extends BaseEditor {
this.toUnbind.push(this.editorControl.getModifiedEditor().onDidBlurEditorWidget(() => this.onEditorFocusLost()));
}
this.toUnbind.push(this.editorGroupService.onEditorsChanged(() => this.onEditorFocusLost()));
this.toUnbind.push(this.editorService.onDidActiveEditorChange(() => this.onEditorFocusLost()));
this.toUnbind.push(DOM.addDisposableListener(window, DOM.EventType.BLUR, () => this.onWindowFocusLost()));
}
......
......@@ -19,12 +19,12 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { once } from 'vs/base/common/event';
import { ScrollType } from 'vs/editor/common/editorCommon';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { CancellationToken } from 'vs/base/common/cancellation';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
/**
* An editor implementation that is capable of showing the contents of resource inputs. Uses
......@@ -39,11 +39,11 @@ export class AbstractTextResourceEditor extends BaseTextEditor {
@IStorageService storageService: IStorageService,
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
@IThemeService themeService: IThemeService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@INextEditorGroupsService editorGroupService: INextEditorGroupsService,
@ITextFileService textFileService: ITextFileService,
@INextEditorGroupsService nextEditorGroupService: INextEditorGroupsService
@INextEditorService editorService: INextEditorService
) {
super(id, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorGroupService, nextEditorGroupService);
super(id, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService);
}
public getTitle(): string {
......@@ -208,10 +208,10 @@ export class TextResourceEditor extends AbstractTextResourceEditor {
@IStorageService storageService: IStorageService,
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
@IThemeService themeService: IThemeService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@ITextFileService textFileService: ITextFileService,
@INextEditorGroupsService nextEditorGroupService: INextEditorGroupsService
@INextEditorService editorService: INextEditorService,
@INextEditorGroupsService editorGroupService: INextEditorGroupsService
) {
super(TextResourceEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, editorGroupService, textFileService, nextEditorGroupService);
super(TextResourceEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, editorGroupService, textFileService, editorService);
}
}
......@@ -10,7 +10,6 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { Action, IAction } from 'vs/base/common/actions';
import { ITree } from 'vs/base/parts/tree/browser/tree';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IViewlet } from 'vs/workbench/common/viewlet';
import { Composite, CompositeDescriptor, CompositeRegistry } from 'vs/workbench/browser/composite';
import { IConstructorSignature0 } from 'vs/platform/instantiation/common/instantiation';
......@@ -18,6 +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';
export abstract class Viewlet extends Composite implements IViewlet {
......@@ -120,7 +120,7 @@ export class ToggleViewletAction extends Action {
name: string,
viewletId: string,
@IViewletService protected viewletService: IViewletService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
@INextEditorService private editorService: INextEditorService
) {
super(id, name);
......@@ -136,7 +136,7 @@ export class ToggleViewletAction extends Action {
}
// Otherwise pass focus to editor if possible
const editor = this.editorService.getActiveEditor();
const editor = this.editorService.activeControl;
if (editor) {
editor.focus();
}
......@@ -176,4 +176,4 @@ export class CollapseAction extends Action {
return TPromise.as(null);
});
}
}
\ No newline at end of file
}
......@@ -37,7 +37,6 @@ import * as service from 'vs/workbench/parts/debug/electron-browser/debugService
import { DebugContentProvider } from 'vs/workbench/parts/debug/browser/debugContentProvider';
import 'vs/workbench/parts/debug/electron-browser/debugEditorContribution';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { registerCommands } from 'vs/workbench/parts/debug/browser/debugCommands';
import { IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
import { StatusBarColorProvider } from 'vs/workbench/parts/debug/browser/statusbarColorProvider';
......@@ -51,6 +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';
class OpenDebugViewletAction extends ToggleViewletAction {
public static readonly ID = VIEWLET_ID;
......@@ -60,7 +60,7 @@ class OpenDebugViewletAction extends ToggleViewletAction {
id: string,
label: string,
@IViewletService viewletService: IViewletService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService
@INextEditorService editorService: INextEditorService
) {
super(id, label, VIEWLET_ID, viewletService, editorService);
}
......
......@@ -13,7 +13,6 @@ import * as paths from 'vs/base/common/paths';
import uri from 'vs/base/common/uri';
import { ITerminalService } from 'vs/workbench/parts/execution/common/execution';
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { Extensions, IConfigurationRegistry, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
import { ITerminalService as IIntegratedTerminalService, KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED } from 'vs/workbench/parts/terminal/common/terminal';
......@@ -28,6 +27,7 @@ import { getMultiSelectedResources } from 'vs/workbench/parts/files/browser/file
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { Schemas } from 'vs/base/common/network';
import { distinct } from 'vs/base/common/arrays';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
if (env.isWindows) {
registerSingleton(ITerminalService, WinTerminalService);
......@@ -81,7 +81,7 @@ CommandsRegistry.registerCommand({
id: OPEN_IN_TERMINAL_COMMAND_ID,
handler: (accessor, resource: uri) => {
const configurationService = accessor.get(IConfigurationService);
const editorService = accessor.get(IWorkbenchEditorService);
const editorService = accessor.get(INextEditorService);
const fileService = accessor.get(IFileService);
const integratedTerminalService = accessor.get(IIntegratedTerminalService);
const terminalService = accessor.get(ITerminalService);
......
......@@ -22,7 +22,6 @@ import { areSameExtensions } from 'vs/platform/extensionManagement/common/extens
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ToggleViewletAction } from 'vs/workbench/browser/viewlet';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { Query } from 'vs/workbench/parts/extensions/common/extensionQuery';
import { IFileService, IContent } from 'vs/platform/files/common/files';
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
......@@ -47,6 +46,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
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';
const promptDownloadManually = (extension: IExtension, message: string, instantiationService: IInstantiationService, notificationService: INotificationService, openerService: IOpenerService) => {
notificationService.prompt(Severity.Error, message, [{
......@@ -957,7 +957,7 @@ export class OpenExtensionsViewletAction extends ToggleViewletAction {
id: string,
label: string,
@IViewletService viewletService: IViewletService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService
@INextEditorService editorService: INextEditorService
) {
super(id, label, VIEWLET_ID, viewletService, editorService);
}
......@@ -1486,7 +1486,7 @@ export abstract class AbstractConfigureRecommendedExtensionsAction extends Actio
label: string,
@IWorkspaceContextService protected contextService: IWorkspaceContextService,
@IFileService private fileService: IFileService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@IJSONEditingService private jsonEditingService: IJSONEditingService,
@ITextModelService private textModelResolverService: ITextModelService
) {
......@@ -1577,7 +1577,7 @@ export class ConfigureWorkspaceRecommendedExtensionsAction extends AbstractConfi
label: string,
@IFileService fileService: IFileService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
@INextEditorService editorService: INextEditorService,
@IJSONEditingService jsonEditingService: IJSONEditingService,
@ITextModelService textModelResolverService: ITextModelService
) {
......@@ -1618,7 +1618,7 @@ export class ConfigureWorkspaceFolderRecommendedExtensionsAction extends Abstrac
label: string,
@IFileService fileService: IFileService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
@INextEditorService editorService: INextEditorService,
@IJSONEditingService jsonEditingService: IJSONEditingService,
@ITextModelService textModelResolverService: ITextModelService,
@ICommandService private commandService: ICommandService
......
......@@ -9,13 +9,13 @@ import { BaseBinaryResourceEditor } from 'vs/workbench/browser/parts/editor/bina
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
import { onUnexpectedError } from 'vs/base/common/errors';
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
import URI from 'vs/base/common/uri';
import { BINARY_FILE_EDITOR_ID } from 'vs/workbench/parts/files/common/files';
import { IFileService } from 'vs/platform/files/common/files';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
/**
* An implementation of editor for binary files like images.
......@@ -29,7 +29,7 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
@IThemeService themeService: IThemeService,
@IFileService fileService: IFileService,
@IWindowsService private windowsService: IWindowsService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
@INextEditorService private editorService: INextEditorService
) {
super(
BinaryFileEditor.ID,
......@@ -46,7 +46,7 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
private openInternal(input: EditorInput, options: EditorOptions): void {
if (input instanceof FileEditorInput) {
input.setForceOpenAsText();
this.editorService.openEditor(input, options, this.group).done(null, onUnexpectedError);
this.editorService.openEditor(input, options, this.group).then(undefined, onUnexpectedError);
}
}
......
......@@ -10,13 +10,11 @@ import * as errors from 'vs/base/common/errors';
import URI from 'vs/base/common/uri';
import * as paths from 'vs/base/common/paths';
import { IEditorViewState } from 'vs/editor/common/editorCommon';
import { toResource, SideBySideEditorInput, IEditorGroup, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor';
import { toResource, SideBySideEditorInput, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor';
import { ITextFileService, ITextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles';
import { FileOperationEvent, FileOperation, IFileService, FileChangeType, FileChangesEvent } from 'vs/platform/files/common/files';
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { distinct } from 'vs/base/common/arrays';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
......@@ -29,6 +27,8 @@ import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { SideBySideEditor } from 'vs/workbench/browser/parts/editor/sideBySideEditor';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { BINARY_FILE_EDITOR_ID } from 'vs/workbench/parts/files/common/files';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService, INextEditorGroup } from 'vs/workbench/services/group/common/nextEditorGroupsService';
export class FileEditorTracker implements IWorkbenchContribution {
......@@ -39,10 +39,10 @@ export class FileEditorTracker implements IWorkbenchContribution {
private activeOutOfWorkspaceWatchers: ResourceMap<URI>;
constructor(
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@ITextFileService private textFileService: ITextFileService,
@ILifecycleService private lifecycleService: ILifecycleService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@INextEditorGroupsService private editorGroupService: INextEditorGroupsService,
@IFileService private fileService: IFileService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IConfigurationService private configurationService: IConfigurationService,
......@@ -67,7 +67,7 @@ export class FileEditorTracker implements IWorkbenchContribution {
this.toUnbind.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
// Editor changing
this.toUnbind.push(this.editorGroupService.onEditorsChanged(() => this.onEditorsChanged()));
this.toUnbind.push(this.editorService.onDidVisibleEditorsChange(() => this.handleOutOfWorkspaceWatchers()));
// Update visible editors when focus is gained
this.toUnbind.push(this.windowService.onDidChangeFocus(e => this.onWindowFocusChange(e)));
......@@ -94,9 +94,9 @@ export class FileEditorTracker implements IWorkbenchContribution {
// are visible in any editor. since this is a fast operation in the case nothing has changed,
// we tolerate the additional work.
distinct(
this.editorService.getVisibleEditors()
.map(editor => {
const resource = toResource(editor.input, { supportSideBySide: true });
this.editorService.visibleEditors
.map(editorInput => {
const resource = toResource(editorInput, { supportSideBySide: true });
return resource ? this.textFileService.models.get(resource) : void 0;
})
.filter(model => model && !model.isDirty()),
......@@ -189,9 +189,8 @@ export class FileEditorTracker implements IWorkbenchContribution {
private getOpenedFileEditors(dirtyState: boolean): FileEditorInput[] {
const editors: FileEditorInput[] = [];
const stacks = this.editorGroupService.getStacksModel();
stacks.groups.forEach(group => {
group.getEditors().forEach(editor => {
this.editorGroupService.groups.forEach(group => {
group.editors.forEach(editor => {
if (editor instanceof FileEditorInput) {
if (!!editor.isDirty() === dirtyState) {
editors.push(editor);
......@@ -219,9 +218,8 @@ export class FileEditorTracker implements IWorkbenchContribution {
}
private handleMovedFileInOpenedEditors(oldResource: URI, newResource: URI): void {
const stacks = this.editorGroupService.getStacksModel();
stacks.groups.forEach(group => {
group.getEditors().forEach(input => {
this.editorGroupService.groups.forEach(group => {
group.editors.forEach(input => {
if (input instanceof FileEditorInput) {
const resource = input.getResource();
......@@ -241,11 +239,11 @@ export class FileEditorTracker implements IWorkbenchContribution {
options: {
preserveFocus: true,
pinned: group.isPinned(input),
index: group.indexOf(input),
index: group.getIndexOfEditor(input),
inactive: !group.isActive(input),
viewState: this.getViewStateFor(oldResource, group)
}
}, stacks.positionOfGroup(group)).done(null, errors.onUnexpectedError);
}, group).then(undefined, errors.onUnexpectedError);
}
}
});
......@@ -269,13 +267,12 @@ export class FileEditorTracker implements IWorkbenchContribution {
return path.indexOf(candidate);
}
private getViewStateFor(resource: URI, group: IEditorGroup): IEditorViewState | undefined {
const stacks = this.editorGroupService.getStacksModel();
const editors = this.editorService.getVisibleEditors();
private getViewStateFor(resource: URI, group: INextEditorGroup): IEditorViewState | undefined {
const editors = this.editorService.visibleControls;
for (let i = 0; i < editors.length; i++) {
const editor = editors[i];
if (editor && editor.input && editor.group === stacks.positionOfGroup(group)) {
if (editor && editor.input && editor.group === group.id) {
const editorResource = editor.input.getResource();
if (editorResource && resource.toString() === editorResource.toString()) {
const control = editor.getControl();
......@@ -299,7 +296,7 @@ export class FileEditorTracker implements IWorkbenchContribution {
}
private handleUpdatesToVisibleBinaryEditors(e: FileChangesEvent): void {
const editors = this.editorService.getVisibleEditors();
const editors = this.editorService.visibleControls;
editors.forEach(editor => {
const resource = toResource(editor.input, { supportSideBySide: true });
......@@ -313,7 +310,7 @@ export class FileEditorTracker implements IWorkbenchContribution {
// Binary editor that should reload from event
if (resource && isBinaryEditor && (e.contains(resource, FileChangeType.UPDATED) || e.contains(resource, FileChangeType.ADDED))) {
this.editorService.openEditor(editor.input, { forceOpen: true, preserveFocus: true }, editor.group).done(null, errors.onUnexpectedError);
this.editorService.openEditor(editor.input, { forceOpen: true, preserveFocus: true }, editor.group).then(null, errors.onUnexpectedError);
}
});
}
......@@ -341,14 +338,10 @@ export class FileEditorTracker implements IWorkbenchContribution {
}
}
private onEditorsChanged(): void {
this.handleOutOfWorkspaceWatchers();
}
private handleOutOfWorkspaceWatchers(): void {
const visibleOutOfWorkspacePaths = new ResourceMap<URI>();
this.editorService.getVisibleEditors().map(editor => {
return toResource(editor.input, { supportSideBySide: true });
this.editorService.visibleEditors.map(editorInput => {
return toResource(editorInput, { supportSideBySide: true });
}).filter(resource => {
return !!resource && this.fileService.canHandleResource(resource) && !this.contextService.isInsideWorkspace(resource);
}).forEach(resource => {
......
......@@ -27,7 +27,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { PreferencesEditor } from 'vs/workbench/parts/preferences/browser/preferencesEditor';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ScrollType } from 'vs/editor/common/editorCommon';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
......@@ -49,15 +48,14 @@ export class TextFileEditor extends BaseTextEditor {
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IStorageService storageService: IStorageService,
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
@INextEditorService private editorService: INextEditorService,
@INextEditorService editorService: INextEditorService,
@IThemeService themeService: IThemeService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@INextEditorGroupsService editorGroupService: INextEditorGroupsService,
@ITextFileService textFileService: ITextFileService,
@IWindowsService private windowsService: IWindowsService,
@IPreferencesService private preferencesService: IPreferencesService,
@INextEditorGroupsService nextEditorGroupService: INextEditorGroupsService
@IPreferencesService private preferencesService: IPreferencesService
) {
super(TextFileEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorGroupService, nextEditorGroupService);
super(TextFileEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService);
// Clear view state for deleted files
this.toUnbind.push(this.fileService.onFileChanges(e => this.onFilesChanged(e)));
......
......@@ -7,15 +7,15 @@
import URI from 'vs/base/common/uri';
import { IListService } from 'vs/platform/list/browser/listService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ExplorerItem, OpenEditor } from 'vs/workbench/parts/files/common/explorerModel';
import { toResource } from 'vs/workbench/common/editor';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { List } from 'vs/base/browser/ui/list/listWidget';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
// Commands can get exeucted from a command pallete, from a context menu or from some list using a keybinding
// To cover all these cases we need to properly compute the resource on which the command is being executed
export function getResourceForCommand(resource: URI | object, listService: IListService, editorService: IWorkbenchEditorService): URI {
export function getResourceForCommand(resource: URI | object, listService: IListService, editorService: INextEditorService): URI {
if (URI.isUri(resource)) {
return resource;
}
......@@ -39,10 +39,10 @@ export function getResourceForCommand(resource: URI | object, listService: IList
}
}
return toResource(editorService.getActiveEditorInput(), { supportSideBySide: true });
return toResource(editorService.activeEditor, { supportSideBySide: true });
}
export function getMultiSelectedResources(resource: URI | object, listService: IListService, editorService: IWorkbenchEditorService): URI[] {
export function getMultiSelectedResources(resource: URI | object, listService: IListService, editorService: INextEditorService): URI[] {
const list = listService.lastFocusedList;
if (list && list.isDOMFocused()) {
// Explorer
......
......@@ -13,35 +13,32 @@ import { TextFileModelChangeEvent, ITextFileService, AutoSaveMode, ModelState }
import { platform, Platform } from 'vs/base/common/platform';
import { Position } from 'vs/platform/editor/common/editor';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IEditorStacksModel } from 'vs/workbench/common/editor';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import URI from 'vs/base/common/uri';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity';
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import * as arrays from 'vs/base/common/arrays';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
export class DirtyFilesTracker implements IWorkbenchContribution {
private isDocumentedEdited: boolean;
private toUnbind: IDisposable[];
private lastDirtyCount: number;
private stacks: IEditorStacksModel;
private badgeHandle: IDisposable;
constructor(
@ITextFileService private textFileService: ITextFileService,
@ILifecycleService private lifecycleService: ILifecycleService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorGroupsService privateeditorGroupService: INextEditorGroupsService,
@INextEditorService private editorService: INextEditorService,
@IActivityService private activityService: IActivityService,
@IWindowService private windowService: IWindowService,
@IUntitledEditorService private untitledEditorService: IUntitledEditorService
) {
this.toUnbind = [];
this.isDocumentedEdited = false;
this.stacks = editorGroupService.getStacksModel();
this.registerListeners();
}
......@@ -88,24 +85,21 @@ export class DirtyFilesTracker implements IWorkbenchContribution {
const shouldOpen = model && model.isDirty() && !model.hasState(ModelState.PENDING_SAVE);
// Only if not open already
return shouldOpen && !this.stacks.isOpen(e.resource);
return shouldOpen && !this.editorService.isOpen({ resource: e.resource });
}).map(e => e.resource), r => r.toString()));
}
private doOpenDirtyResources(resources: URI[]): void {
const activeEditor = this.editorService.getActiveEditor();
const activeEditor = this.editorService.activeControl;
const activePosition = activeEditor ? activeEditor.group : Position.ONE;
// Open
this.editorService.openEditors(resources.map(resource => {
return {
input: {
resource,
options: { inactive: true, pinned: true, preserveFocus: true }
},
position: activePosition
resource,
options: { inactive: true, pinned: true, preserveFocus: true }
};
})).done(null, errors.onUnexpectedError);
}), activePosition).then(undefined, errors.onUnexpectedError);
}
private onTextFilesSaved(e: TextFileModelChangeEvent[]): void {
......
......@@ -30,9 +30,7 @@ import { ExplorerItem, Model, NewStatPlaceholder } from 'vs/workbench/parts/file
import { ExplorerView } from 'vs/workbench/parts/files/electron-browser/views/explorerView';
import { ExplorerViewlet } from 'vs/workbench/parts/files/electron-browser/explorerViewlet';
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { CollapseAction } from 'vs/workbench/browser/viewlet';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IInstantiationService, ServicesAccessor, IConstructorSignature2 } from 'vs/platform/instantiation/common/instantiation';
......@@ -52,6 +50,7 @@ import { RawContextKey, IContextKeyService } from 'vs/platform/contextkey/common
import { Schemas } from 'vs/base/common/network';
import { IDialogService, IConfirmationResult, IConfirmation, getConfirmMessage } from 'vs/platform/dialogs/common/dialogs';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
export interface IEditableData {
action: IAction;
......@@ -482,7 +481,7 @@ export class GlobalNewUntitledFileAction extends Action {
constructor(
id: string,
label: string,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
@INextEditorService private editorService: INextEditorService
) {
super(id, label);
}
......@@ -513,7 +512,7 @@ class CreateFileAction extends BaseCreateAction {
constructor(
element: ExplorerItem,
@IFileService fileService: IFileService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@INotificationService notificationService: INotificationService,
@ITextFileService textFileService: ITextFileService
) {
......@@ -791,7 +790,7 @@ export class AddFilesAction extends BaseFileAction {
element: ExplorerItem,
clazz: string,
@IFileService fileService: IFileService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@IDialogService private dialogService: IDialogService,
@INotificationService notificationService: INotificationService,
@ITextFileService textFileService: ITextFileService
......@@ -946,7 +945,7 @@ class PasteFileAction extends BaseFileAction {
@IFileService fileService: IFileService,
@INotificationService notificationService: INotificationService,
@ITextFileService textFileService: ITextFileService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
@INextEditorService private editorService: INextEditorService
) {
super(PasteFileAction.ID, PASTE_FILE_LABEL, fileService, notificationService, textFileService);
......@@ -1009,7 +1008,7 @@ export class DuplicateFileAction extends BaseFileAction {
fileToDuplicate: ExplorerItem,
target: ExplorerItem,
@IFileService fileService: IFileService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@INotificationService notificationService: INotificationService,
@ITextFileService textFileService: ITextFileService
) {
......@@ -1089,20 +1088,19 @@ export class GlobalCompareResourcesAction extends Action {
id: string,
label: string,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@INotificationService private notificationService: INotificationService,
@IEditorGroupService private editorGroupService: IEditorGroupService
) {
super(id, label);
}
public run(): TPromise<any> {
const activeInput = this.editorService.getActiveEditorInput();
const activeInput = this.editorService.activeEditor;
const activeResource = activeInput ? activeInput.getResource() : void 0;
if (activeResource) {
// Compare with next editor that opens
const unbind = once(this.editorGroupService.onEditorOpening)(e => {
const unbind = once(this.editorService.onWillOpenEditor)(e => {
const resource = e.editor.getResource();
if (resource) {
e.prevent(() => {
......@@ -1284,7 +1282,7 @@ export class ShowActiveFileInExplorer extends Action {
constructor(
id: string,
label: string,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@INotificationService private notificationService: INotificationService,
@ICommandService private commandService: ICommandService
) {
......@@ -1292,7 +1290,7 @@ export class ShowActiveFileInExplorer extends Action {
}
public run(): TPromise<any> {
const resource = toResource(this.editorService.getActiveEditorInput(), { supportSideBySide: true });
const resource = toResource(this.editorService.activeEditor, { supportSideBySide: true });
if (resource) {
this.commandService.executeCommand(REVEAL_IN_EXPLORER_COMMAND_ID, resource);
} else {
......@@ -1363,14 +1361,14 @@ export class ShowOpenedFileInNewWindow extends Action {
id: string,
label: string,
@IWindowsService private windowsService: IWindowsService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@INotificationService private notificationService: INotificationService,
) {
super(id, label);
}
public run(): TPromise<any> {
const fileResource = toResource(this.editorService.getActiveEditorInput(), { supportSideBySide: true, filter: Schemas.file /* todo@remote */ });
const fileResource = toResource(this.editorService.activeEditor, { supportSideBySide: true, filter: Schemas.file /* todo@remote */ });
if (fileResource) {
this.windowsService.openWindow([fileResource.fsPath], { forceNewWindow: true, forceOpenWorkspaceAsFile: true });
} else {
......@@ -1474,7 +1472,7 @@ export class CompareWithClipboardAction extends Action {
constructor(
id: string,
label: string,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@IInstantiationService private instantiationService: IInstantiationService,
@ITextModelService private textModelService: ITextModelService,
@IFileService private fileService: IFileService
......@@ -1485,7 +1483,7 @@ export class CompareWithClipboardAction extends Action {
}
public run(): TPromise<any> {
const resource: URI = toResource(this.editorService.getActiveEditorInput(), { supportSideBySide: true });
const resource: URI = toResource(this.editorService.activeEditor, { supportSideBySide: true });
if (resource && (this.fileService.canHandleResource(resource) || resource.scheme === Schemas.untitled)) {
if (!this.registrationDisposal) {
const provider = this.instantiationService.createInstance(ClipboardContentProvider);
......
......@@ -10,7 +10,6 @@ import * as paths from 'vs/base/common/paths';
import { TPromise } from 'vs/base/common/winjs.base';
import * as labels from 'vs/base/common/labels';
import URI from 'vs/base/common/uri';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { toResource, IEditorCommandsContext } from 'vs/workbench/common/editor';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
......@@ -19,7 +18,6 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import { ExplorerFocusCondition, FileOnDiskContentProvider, VIEWLET_ID } from 'vs/workbench/parts/files/common/files';
import { ExplorerViewlet } from 'vs/workbench/parts/files/electron-browser/explorerViewlet';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { IListService } from 'vs/platform/list/browser/listService';
......@@ -42,6 +40,8 @@ import { getMultiSelectedEditorContexts } from 'vs/workbench/browser/parts/edito
import { Schemas } from 'vs/base/common/network';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { INextEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/nextEditorService';
import { INextEditorGroupsService, GroupDirection } from 'vs/workbench/services/group/common/nextEditorGroupsService';
// Commands
......@@ -81,8 +81,8 @@ export const openWindowCommand = (accessor: ServicesAccessor, paths: string[], f
windowsService.openWindow(paths, { forceNewWindow });
};
function save(resource: URI, isSaveAs: boolean, editorService: IWorkbenchEditorService, fileService: IFileService, untitledEditorService: IUntitledEditorService,
textFileService: ITextFileService, editorGroupService: IEditorGroupService): TPromise<any> {
function save(resource: URI, isSaveAs: boolean, editorService: INextEditorService, fileService: IFileService, untitledEditorService: IUntitledEditorService,
textFileService: ITextFileService, editorGroupService: INextEditorGroupsService): TPromise<any> {
if (resource && (fileService.canHandleResource(resource) || resource.scheme === Schemas.untitled)) {
......@@ -97,7 +97,7 @@ function save(resource: URI, isSaveAs: boolean, editorService: IWorkbenchEditorS
}
let viewStateOfSource: IEditorViewState;
const activeEditor = editorService.getActiveEditor();
const activeEditor = editorService.activeControl;
const editor = getCodeEditor(activeEditor);
if (editor) {
const activeResource = toResource(activeEditor.input, { supportSideBySide: true });
......@@ -136,19 +136,21 @@ function save(resource: URI, isSaveAs: boolean, editorService: IWorkbenchEditorS
viewState: viewStateOfSource
}
};
console.log(replaceWith);
return editorService.replaceEditors([{
toReplace: { resource: resource },
replaceWith
}]).then(() => true);
// TODO@Isidor
// return editorService.replaceEditors([{
// toReplace: { resource: resource },
// replaceWith
// }]).then(() => true);
});
}
// Pin the active editor if we are saving it
const editor = editorService.getActiveEditor();
const editor = editorService.activeControl;
const activeEditorResource = editor && editor.input && editor.input.getResource();
if (activeEditorResource && activeEditorResource.toString() === resource.toString()) {
editorGroupService.pinEditor(editor.group, editor.input);
editorGroupService.getGroup(editor.group).pinEditor(editor.input);
}
// Just save
......@@ -158,10 +160,8 @@ function save(resource: URI, isSaveAs: boolean, editorService: IWorkbenchEditorS
return TPromise.as(false);
}
function saveAll(saveAllArguments: any, editorService: IWorkbenchEditorService, untitledEditorService: IUntitledEditorService,
textFileService: ITextFileService, editorGroupService: IEditorGroupService): TPromise<any> {
const stacks = editorGroupService.getStacksModel();
function saveAll(saveAllArguments: any, editorService: INextEditorService, untitledEditorService: IUntitledEditorService,
textFileService: ITextFileService, editorGroupService: INextEditorGroupsService): TPromise<any> {
// Store some properties per untitled file to restore later after save is completed
const mapUntitledToProperties: { [resource: string]: { encoding: string; indexInGroups: number[]; activeInGroups: boolean[] } } = Object.create(null);
......@@ -171,7 +171,7 @@ function saveAll(saveAllArguments: any, editorService: IWorkbenchEditorService,
const encoding = untitledEditorService.getEncoding(resource);
// For each group
stacks.groups.forEach((group, groupIndex) => {
editorGroupService.groups.forEach((group, groupIndex) => {
// Find out if editor is active in group
const activeEditor = group.activeEditor;
......@@ -180,7 +180,7 @@ function saveAll(saveAllArguments: any, editorService: IWorkbenchEditorService,
// Find index of editor in group
indexInGroups[groupIndex] = -1;
group.getEditors().forEach((editor, editorIndex) => {
group.editors.forEach((editor, editorIndex) => {
const editorResource = toResource(editor, { supportSideBySide: true });
if (editorResource && editorResource.toString() === resource.toString()) {
indexInGroups[groupIndex] = editorIndex;
......@@ -227,10 +227,10 @@ function saveAll(saveAllArguments: any, editorService: IWorkbenchEditorService,
}
});
});
if (untitledToReopen.length) {
return editorService.openEditors(untitledToReopen).then(() => true);
}
// TODO@Isidor
// if (untitledToReopen.length) {
// return editorService.openEditors(untitledToReopen).then(() => true);
// }
return void 0;
});
......@@ -241,7 +241,7 @@ function saveAll(saveAllArguments: any, editorService: IWorkbenchEditorService,
CommandsRegistry.registerCommand({
id: REVERT_FILE_COMMAND_ID,
handler: (accessor, resource: URI | object) => {
const editorService = accessor.get(IWorkbenchEditorService);
const editorService = accessor.get(INextEditorService);
const textFileService = accessor.get(ITextFileService);
const notificationService = accessor.get(INotificationService);
const resources = getMultiSelectedResources(resource, accessor.get(IListService), editorService)
......@@ -265,14 +265,13 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
primary: KeyMod.WinCtrl | KeyCode.Enter
},
id: OPEN_TO_SIDE_COMMAND_ID, handler: (accessor, resource: URI | object) => {
const editorService = accessor.get(IWorkbenchEditorService);
const editorGroupService = accessor.get(IEditorGroupService);
const editorService = accessor.get(INextEditorService);
const editorGroupService = accessor.get(INextEditorGroupsService);
const listService = accessor.get(IListService);
const fileService = accessor.get(IFileService);
const tree = listService.lastFocusedList;
const resources = getMultiSelectedResources(resource, listService, editorService);
const stacks = editorGroupService.getStacksModel();
const activeGroup = stacks.activeGroup;
const activeGroup = editorGroupService.activeGroup;
// Remove highlight
if (tree instanceof Tree) {
......@@ -283,15 +282,13 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
if (resources.length) {
return fileService.resolveFiles(resources.map(resource => ({ resource }))).then(resolved => {
const editors = resolved.filter(r => r.success && !r.stat.isDirectory).map(r => ({
input: {
resource: r.stat.resource,
options: { preserveFocus: false }
}
resource: r.stat.resource,
options: { preserveFocus: false }
}));
return editorService.openEditors(editors, true).then(() => {
return editorService.openEditors(editors, SIDE_GROUP).then(() => {
if (activeGroup) {
editorGroupService.focusGroup(stacks.positionOfGroup(activeGroup) + 1);
editorGroupService.focusGroup(editorGroupService.findNeighbourGroup(activeGroup, GroupDirection.RIGHT));
}
});
});
......@@ -316,7 +313,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
textModelService.registerTextModelContentProvider(COMPARE_WITH_SAVED_SCHEMA, provider);
}
const editorService = accessor.get(IWorkbenchEditorService);
const editorService = accessor.get(INextEditorService);
const uri = getResourceForCommand(resource, accessor.get(IListService), editorService);
if (uri && uri.scheme === Schemas.file /* only files on disk supported for now */) {
......@@ -343,7 +340,7 @@ CommandsRegistry.registerCommand({
tree.domFocus();
}
globalResourceToCompare = getResourceForCommand(resource, listService, accessor.get(IWorkbenchEditorService));
globalResourceToCompare = getResourceForCommand(resource, listService, accessor.get(INextEditorService));
if (!resourceSelectedForCompareContext) {
resourceSelectedForCompareContext = ResourceSelectedForCompareContext.bindTo(accessor.get(IContextKeyService));
}
......@@ -354,7 +351,7 @@ CommandsRegistry.registerCommand({
CommandsRegistry.registerCommand({
id: COMPARE_SELECTED_COMMAND_ID,
handler: (accessor, resource: URI | object) => {
const editorService = accessor.get(IWorkbenchEditorService);
const editorService = accessor.get(INextEditorService);
const resources = getMultiSelectedResources(resource, accessor.get(IListService), editorService);
if (resources.length === 2) {
......@@ -371,7 +368,7 @@ CommandsRegistry.registerCommand({
CommandsRegistry.registerCommand({
id: COMPARE_RESOURCE_COMMAND_ID,
handler: (accessor, resource: URI | object) => {
const editorService = accessor.get(IWorkbenchEditorService);
const editorService = accessor.get(INextEditorService);
const listService = accessor.get(IListService);
const tree = listService.lastFocusedList;
......@@ -405,7 +402,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_R
},
handler: (accessor: ServicesAccessor, resource: URI | object) => {
const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(IWorkbenchEditorService));
const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(INextEditorService));
revealResourcesInOS(resources, accessor.get(IWindowsService), accessor.get(INotificationService), accessor.get(IWorkspaceContextService));
}
});
......@@ -415,8 +412,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_R),
id: 'workbench.action.files.revealActiveFileInWindows',
handler: (accessor: ServicesAccessor) => {
const editorService = accessor.get(IWorkbenchEditorService);
const activeInput = editorService.getActiveEditorInput();
const editorService = accessor.get(INextEditorService);
const activeInput = editorService.activeEditor;
const resources = activeInput && activeInput.getResource() ? [activeInput.getResource()] : [];
revealResourcesInOS(resources, accessor.get(IWindowsService), accessor.get(INotificationService), accessor.get(IWorkspaceContextService));
}
......@@ -440,7 +437,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
},
id: COPY_PATH_COMMAND_ID,
handler: (accessor, resource: URI | object) => {
const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(IWorkbenchEditorService));
const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(INextEditorService));
resourcesToClipboard(resources, accessor.get(IClipboardService), accessor.get(INotificationService));
}
});
......@@ -451,8 +448,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_P),
id: 'workbench.action.files.copyPathOfActiveFile',
handler: (accessor) => {
const editorService = accessor.get(IWorkbenchEditorService);
const activeInput = editorService.getActiveEditorInput();
const editorService = accessor.get(INextEditorService);
const activeInput = editorService.activeEditor;
const resources = activeInput && activeInput.getResource() ? [activeInput.getResource()] : [];
resourcesToClipboard(resources, accessor.get(IClipboardService), accessor.get(INotificationService));
}
......@@ -463,7 +460,7 @@ CommandsRegistry.registerCommand({
handler: (accessor, resource: URI | object) => {
const viewletService = accessor.get(IViewletService);
const contextService = accessor.get(IWorkspaceContextService);
const uri = getResourceForCommand(resource, accessor.get(IListService), accessor.get(IWorkbenchEditorService));
const uri = getResourceForCommand(resource, accessor.get(IListService), accessor.get(INextEditorService));
viewletService.openViewlet(VIEWLET_ID, false).then((viewlet: ExplorerViewlet) => {
const isInsideWorkspace = contextService.isInsideWorkspace(uri);
......@@ -489,15 +486,15 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
when: undefined,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_S,
handler: (accessor, resourceOrObject: URI | object | { from: string }) => {
const editorService = accessor.get(IWorkbenchEditorService);
const editorService = accessor.get(INextEditorService);
let resource: URI = undefined;
if (resourceOrObject && 'from' in resourceOrObject && resourceOrObject.from === 'menu') {
resource = toResource(editorService.getActiveEditorInput());
resource = toResource(editorService.activeEditor);
} else {
resource = getResourceForCommand(resourceOrObject, accessor.get(IListService), editorService);
}
return save(resource, true, editorService, accessor.get(IFileService), accessor.get(IUntitledEditorService), accessor.get(ITextFileService), accessor.get(IEditorGroupService));
return save(resource, true, editorService, accessor.get(IFileService), accessor.get(IUntitledEditorService), accessor.get(ITextFileService), accessor.get(INextEditorGroupsService));
}
});
......@@ -507,29 +504,29 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
primary: KeyMod.CtrlCmd | KeyCode.KEY_S,
id: SAVE_FILE_COMMAND_ID,
handler: (accessor, resource: URI | object) => {
const editorService = accessor.get(IWorkbenchEditorService);
const editorService = accessor.get(INextEditorService);
const resources = getMultiSelectedResources(resource, accessor.get(IListService), editorService);
if (resources.length === 1) {
// If only one resource is selected explictly call save since the behavior is a bit different than save all #41841
return save(resources[0], false, editorService, accessor.get(IFileService), accessor.get(IUntitledEditorService), accessor.get(ITextFileService), accessor.get(IEditorGroupService));
return save(resources[0], false, editorService, accessor.get(IFileService), accessor.get(IUntitledEditorService), accessor.get(ITextFileService), accessor.get(INextEditorGroupsService));
}
return saveAll(resources, editorService, accessor.get(IUntitledEditorService), accessor.get(ITextFileService), accessor.get(IEditorGroupService));
return saveAll(resources, editorService, accessor.get(IUntitledEditorService), accessor.get(ITextFileService), accessor.get(INextEditorGroupsService));
}
});
CommandsRegistry.registerCommand({
id: SAVE_ALL_COMMAND_ID,
handler: (accessor) => {
return saveAll(true, accessor.get(IWorkbenchEditorService), accessor.get(IUntitledEditorService), accessor.get(ITextFileService), accessor.get(IEditorGroupService));
return saveAll(true, accessor.get(INextEditorService), accessor.get(IUntitledEditorService), accessor.get(ITextFileService), accessor.get(INextEditorGroupsService));
}
});
CommandsRegistry.registerCommand({
id: SAVE_ALL_IN_GROUP_COMMAND_ID,
handler: (accessor, resource: URI | object, editorContext: IEditorCommandsContext) => {
const contexts = getMultiSelectedEditorContexts(editorContext, accessor.get(IListService), accessor.get(IEditorGroupService));
const editorGroupService = accessor.get(IEditorGroupService);
const contexts = getMultiSelectedEditorContexts(editorContext, accessor.get(IListService), accessor.get(INextEditorGroupsService));
const editorGroupService = accessor.get(INextEditorGroupsService);
let saveAllArg: any;
if (!contexts.length) {
saveAllArg = true;
......@@ -537,8 +534,8 @@ CommandsRegistry.registerCommand({
const fileService = accessor.get(IFileService);
saveAllArg = [];
contexts.forEach(context => {
const editorGroup = editorGroupService.getStacksModel().getGroup(context.groupId);
editorGroup.getEditors().forEach(editor => {
const editorGroup = editorGroupService.getGroup(context.groupId);
editorGroup.editors.forEach(editor => {
const resource = toResource(editor, { supportSideBySide: true });
if (resource && (resource.scheme === Schemas.untitled || fileService.canHandleResource(resource))) {
saveAllArg.push(resource);
......@@ -547,14 +544,14 @@ CommandsRegistry.registerCommand({
});
}
return saveAll(saveAllArg, accessor.get(IWorkbenchEditorService), accessor.get(IUntitledEditorService), accessor.get(ITextFileService), accessor.get(IEditorGroupService));
return saveAll(saveAllArg, accessor.get(INextEditorService), accessor.get(IUntitledEditorService), accessor.get(ITextFileService), accessor.get(INextEditorGroupsService));
}
});
CommandsRegistry.registerCommand({
id: SAVE_FILES_COMMAND_ID,
handler: (accessor) => {
return saveAll(false, accessor.get(IWorkbenchEditorService), accessor.get(IUntitledEditorService), accessor.get(ITextFileService), accessor.get(IEditorGroupService));
return saveAll(false, accessor.get(INextEditorService), accessor.get(IUntitledEditorService), accessor.get(ITextFileService), accessor.get(INextEditorGroupsService));
}
});
......@@ -564,7 +561,7 @@ CommandsRegistry.registerCommand({
const workspaceEditingService = accessor.get(IWorkspaceEditingService);
const contextService = accessor.get(IWorkspaceContextService);
const workspace = contextService.getWorkspace();
const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(IWorkbenchEditorService)).filter(r =>
const resources = getMultiSelectedResources(resource, accessor.get(IListService), accessor.get(INextEditorService)).filter(r =>
// Need to verify resources are workspaces since multi selection can trigger this command on some non workspace resources
workspace.folders.some(f => f.uri.toString() === r.toString())
);
......
......@@ -25,7 +25,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import * as platform from 'vs/base/common/platform';
import { DirtyFilesTracker } from 'vs/workbench/parts/files/common/dirtyFilesTracker';
......@@ -33,6 +32,7 @@ import { ExplorerViewlet, ExplorerViewletViewsContribution } from 'vs/workbench/
import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
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';
// Viewlet Action
export class OpenExplorerViewletAction extends ToggleViewletAction {
......@@ -43,7 +43,7 @@ export class OpenExplorerViewletAction extends ToggleViewletAction {
id: string,
label: string,
@IViewletService viewletService: IViewletService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService
@INextEditorService editorService: INextEditorService
) {
super(id, label, VIEWLET_ID, viewletService, editorService);
}
......@@ -136,7 +136,7 @@ class FileEditorInputFactory implements IEditorInputFactory {
const resource = !!fileInput.resourceJSON ? URI.revive(fileInput.resourceJSON) : URI.parse(fileInput.resource);
const encoding = fileInput.encoding;
return accessor.get(IWorkbenchEditorService).createInput({ resource, encoding }) as FileEditorInput;
return accessor.get(INextEditorService).createInput({ resource, encoding }) as FileEditorInput;
});
}
}
......
......@@ -12,7 +12,6 @@ import * as paths from 'vs/base/common/paths';
import { Action } from 'vs/base/common/actions';
import URI from 'vs/base/common/uri';
import { FileOperationError, FileOperationResult } from 'vs/platform/files/common/files';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ITextFileService, ISaveErrorHandler, ITextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles';
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
......@@ -20,7 +19,6 @@ import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { ResourceMap } from 'vs/base/common/map';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { IContextKeyService, IContextKey, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
......@@ -35,6 +33,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
import { ExecuteCommandAction } from 'vs/platform/actions/common/actions';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { once } from 'vs/base/common/event';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
export const CONFLICT_RESOLUTION_CONTEXT = 'saveConflictResolutionContext';
export const CONFLICT_RESOLUTION_SCHEME = 'conflictResolution';
......@@ -53,9 +52,8 @@ export class SaveErrorHandler implements ISaveErrorHandler, IWorkbenchContributi
constructor(
@INotificationService private notificationService: INotificationService,
@ITextFileService private textFileService: ITextFileService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IContextKeyService contextKeyService: IContextKeyService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@ITextModelService textModelService: ITextModelService,
@IInstantiationService private instantiationService: IInstantiationService,
@IStorageService private storageService: IStorageService
......@@ -79,19 +77,19 @@ export class SaveErrorHandler implements ISaveErrorHandler, IWorkbenchContributi
private registerListeners(): void {
this.toUnbind.push(this.textFileService.models.onModelSaved(e => this.onFileSavedOrReverted(e.resource)));
this.toUnbind.push(this.textFileService.models.onModelReverted(e => this.onFileSavedOrReverted(e.resource)));
this.toUnbind.push(this.editorGroupService.onEditorsChanged(() => this.onEditorsChanged()));
this.toUnbind.push(this.editorService.onDidActiveEditorChange(() => this.onEditorsChanged()));
}
private onEditorsChanged(): void {
let isActiveEditorSaveConflictResolution = false;
let activeConflictResolutionResource: URI;
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && activeEditor.input instanceof DiffEditorInput && activeEditor.input.originalInput instanceof ResourceEditorInput && activeEditor.input.modifiedInput instanceof FileEditorInput) {
const resource = activeEditor.input.originalInput.getResource();
const activeInput = this.editorService.activeEditor;
if (activeInput instanceof DiffEditorInput && activeInput.originalInput instanceof ResourceEditorInput && activeInput.modifiedInput instanceof FileEditorInput) {
const resource = activeInput.originalInput.getResource();
if (resource && resource.scheme === CONFLICT_RESOLUTION_SCHEME) {
isActiveEditorSaveConflictResolution = true;
activeConflictResolutionResource = activeEditor.input.modifiedInput.getResource();
activeConflictResolutionResource = activeInput.modifiedInput.getResource();
}
}
......@@ -232,7 +230,7 @@ class ResolveSaveConflictAction extends Action {
constructor(
private model: ITextFileEditorModel,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@INotificationService private notificationService: INotificationService,
@IInstantiationService private instantiationService: IInstantiationService,
@IStorageService private storageService: IStorageService,
......@@ -313,11 +311,11 @@ class OverwriteReadonlyAction extends Action {
}
export const acceptLocalChangesCommand = (accessor: ServicesAccessor, resource: URI) => {
const editorService = accessor.get(IWorkbenchEditorService);
const editorService = accessor.get(INextEditorService);
const resolverService = accessor.get(ITextModelService);
const modelService = accessor.get(IModelService);
const editor = editorService.getActiveEditor();
const editor = editorService.activeControl;
const input = editor.input;
const position = editor.group;
......@@ -342,7 +340,7 @@ export const acceptLocalChangesCommand = (accessor: ServicesAccessor, resource:
// Clean up
input.dispose();
reference.dispose();
editorService.closeEditor(position, input);
editorService.closeEditor(input, position);
});
});
});
......@@ -350,10 +348,10 @@ export const acceptLocalChangesCommand = (accessor: ServicesAccessor, resource:
};
export const revertLocalChangesCommand = (accessor: ServicesAccessor, resource: URI) => {
const editorService = accessor.get(IWorkbenchEditorService);
const editorService = accessor.get(INextEditorService);
const resolverService = accessor.get(ITextModelService);
const editor = editorService.getActiveEditor();
const editor = editorService.activeControl;
const input = editor.input;
const position = editor.group;
......@@ -371,7 +369,7 @@ export const revertLocalChangesCommand = (accessor: ServicesAccessor, resource:
// Clean up
input.dispose();
reference.dispose();
editorService.closeEditor(position, input);
editorService.closeEditor(input, position);
});
});
});
......
......@@ -20,12 +20,10 @@ import { RefreshViewExplorerAction, NewFolderAction, NewFileAction } from 'vs/wo
import { FileDragAndDrop, FileFilter, FileSorter, FileController, FileRenderer, FileDataSource, FileViewletState, FileAccessibilityProvider } from 'vs/workbench/parts/files/electron-browser/views/explorerViewer';
import { toResource } from 'vs/workbench/common/editor';
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import * as DOM from 'vs/base/browser/dom';
import { CollapseAction } from 'vs/workbench/browser/viewlet';
import { IViewletViewOptions, IViewOptions, TreeViewsViewletPanel, FileIconThemableWorkbenchTree } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { ExplorerItem, Model } from 'vs/workbench/parts/files/common/explorerModel';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { ExplorerDecorationsProvider } from 'vs/workbench/parts/files/electron-browser/views/explorerDecorationsProvider';
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
......@@ -43,6 +41,7 @@ import { WorkbenchTree } from 'vs/platform/list/browser/listService';
import { DelayedDragHandler } from 'vs/base/browser/dnd';
import { Schemas } from 'vs/base/common/network';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
export interface IExplorerViewOptions extends IViewletViewOptions {
viewletState: FileViewletState;
......@@ -84,10 +83,9 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
@INotificationService private notificationService: INotificationService,
@IContextMenuService contextMenuService: IContextMenuService,
@IInstantiationService private instantiationService: IInstantiationService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IProgressService private progressService: IProgressService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@IFileService private fileService: IFileService,
@IPartService private partService: IPartService,
@IKeybindingService keybindingService: IKeybindingService,
......@@ -201,7 +199,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
return this.doRefresh(targetsToExpand).then(() => {
// When the explorer viewer is loaded, listen to changes to the editor input
this.disposables.push(this.editorGroupService.onEditorsChanged(() => this.revealActiveFile()));
this.disposables.push(this.editorService.onDidActiveEditorChange(() => this.revealActiveFile()));
// Also handle configuration updates
this.disposables.push(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(this.configurationService.getValue<IFilesConfiguration>(), e)));
......@@ -237,7 +235,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
}
// Handle closed or untitled file (convince explorer to not reopen any file when getting visible)
const activeInput = this.editorService.getActiveEditorInput();
const activeInput = this.editorService.activeEditor;
if (!activeInput || toResource(activeInput, { supportSideBySide: true, filter: Schemas.untitled })) {
this.settings[ExplorerView.MEMENTO_LAST_ACTIVE_FILE_RESOURCE] = void 0;
clearFocus = true;
......@@ -347,7 +345,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
}
if (lastActiveFileResource && this.isCreated && this.model.findClosest(lastActiveFileResource)) {
this.editorService.openEditor({ resource: lastActiveFileResource, options: { revealIfVisible: true } }).done(null, errors.onUnexpectedError);
this.editorService.openEditor({ resource: lastActiveFileResource, options: { revealIfVisible: true } }).then(null, errors.onUnexpectedError);
return refreshPromise;
}
......@@ -365,12 +363,12 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
private openFocusedElement(preserveFocus?: boolean): void {
const stat: ExplorerItem = this.explorerViewer.getFocus();
if (stat && !stat.isDirectory) {
this.editorService.openEditor({ resource: stat.resource, options: { preserveFocus, revealIfVisible: true } }).done(null, errors.onUnexpectedError);
this.editorService.openEditor({ resource: stat.resource, options: { preserveFocus, revealIfVisible: true } }).then(null, errors.onUnexpectedError);
}
}
private getActiveFile(): URI {
const input = this.editorService.getActiveEditorInput();
const input = this.editorService.activeEditor;
// ignore diff editor inputs (helps to get out of diffing when returning to explorer)
if (input instanceof DiffEditorInput) {
......
......@@ -30,7 +30,6 @@ import { DesktopDragAndDropData, ExternalElementsDragAndDropData } from 'vs/base
import { ClickBehavior } from 'vs/base/parts/tree/browser/treeDefaults';
import { ExplorerItem, NewStatPlaceholder, Model } from 'vs/workbench/parts/files/common/explorerModel';
import { DragMouseEvent, IMouseEvent } from 'vs/base/browser/mouseEvent';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
......@@ -57,6 +56,7 @@ import { IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/work
import { rtrim } from 'vs/base/common/strings';
import { IDialogService, IConfirmationResult, IConfirmation, getConfirmMessage } from 'vs/platform/dialogs/common/dialogs';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { INextEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/nextEditorService';
export class FileDataSource implements IDataSource {
constructor(
......@@ -395,7 +395,7 @@ export class FileController extends WorkbenchTreeController implements IDisposab
private previousSelectionRangeStop: ExplorerItem;
constructor(
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INextEditorService private editorService: INextEditorService,
@IContextMenuService private contextMenuService: IContextMenuService,
@ITelemetryService private telemetryService: ITelemetryService,
@IMenuService private menuService: IMenuService,
......@@ -551,7 +551,7 @@ export class FileController extends WorkbenchTreeController implements IDisposab
*/
this.telemetryService.publicLog('workbenchActionExecuted', { id: 'workbench.files.openFile', from: 'explorer' });
this.editorService.openEditor({ resource: stat.resource, options }, options.sideBySide).done(null, errors.onUnexpectedError);
this.editorService.openEditor({ resource: stat.resource, options }, SIDE_GROUP).then(null, errors.onUnexpectedError);
}
}
......
......@@ -9,14 +9,14 @@ import URI from 'vs/base/common/uri';
import { join } from 'vs/base/common/paths';
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { workbenchInstantiationService, TestTextFileService, TestEditorGroupService } from 'vs/workbench/test/workbenchTestServices';
import { workbenchInstantiationService, TestTextFileService } from 'vs/workbench/test/workbenchTestServices';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { EncodingMode, Verbosity } from 'vs/workbench/common/editor';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { FileOperationResult, FileOperationError } from 'vs/platform/files/common/files';
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { IModelService } from 'vs/editor/common/services/modelService';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
function toResource(self, path) {
return URI.file(join('C:\\', Buffer.from(self.test.fullTitle()).toString('base64'), path));
......@@ -27,7 +27,7 @@ class ServiceAccessor {
@IWorkbenchEditorService public editorService: IWorkbenchEditorService,
@ITextFileService public textFileService: TestTextFileService,
@IModelService public modelService: IModelService,
@IEditorGroupService public editorGroupService: TestEditorGroupService
@INextEditorGroupsService public editorGroupService: INextEditorGroupsService
) {
}
}
......@@ -184,4 +184,4 @@ suite('Files - FileEditorInput', () => {
resolved.dispose();
});
});
});
\ No newline at end of file
});
......@@ -13,10 +13,10 @@ import { join } from 'vs/base/common/paths';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { workbenchInstantiationService, TestTextFileService, TestFileService } from 'vs/workbench/test/workbenchTestServices';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { /*FileOperation, FileOperationEvent,*/ FileChangesEvent, FileChangeType, IFileService, snapshotToString } from 'vs/platform/files/common/files';
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
// import { once } from 'vs/base/common/event';
// class TestFileEditorTracker extends FileEditorTracker {
......@@ -33,7 +33,7 @@ function toResource(self: any, path: string) {
class ServiceAccessor {
constructor(
@IWorkbenchEditorService public editorService: IWorkbenchEditorService,
@IEditorGroupService public editorGroupService: IEditorGroupService,
@INextEditorGroupsService public editorGroupService: INextEditorGroupsService,
@ITextFileService public textFileService: TestTextFileService,
@IFileService public fileService: TestFileService
) {
......
......@@ -11,7 +11,6 @@ import { ITextResourceConfigurationService } from 'vs/editor/common/services/res
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { AbstractTextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
......@@ -20,7 +19,7 @@ import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
import { LOG_SCHEME } from 'vs/workbench/parts/output/common/output';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
export class LogViewerInput extends ResourceEditorInput {
......@@ -53,11 +52,11 @@ export class LogViewer extends AbstractTextResourceEditor {
@IConfigurationService baseConfigurationService: IConfigurationService,
@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService,
@IThemeService themeService: IThemeService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@INextEditorGroupsService editorGroupService: INextEditorGroupsService,
@ITextFileService textFileService: ITextFileService,
@INextEditorGroupsService nextEditorGroupService: INextEditorGroupsService
@INextEditorService editorService: INextEditorService
) {
super(LogViewer.LOG_VIEWER_EDITOR_ID, telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorGroupService, textFileService, nextEditorGroupService);
super(LogViewer.LOG_VIEWER_EDITOR_ID, telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorGroupService, textFileService, editorService);
}
protected getConfigurationOverrides(): IEditorOptions {
......
......@@ -20,11 +20,11 @@ import { AbstractTextResourceEditor } from 'vs/workbench/browser/parts/editor/te
import { OUTPUT_PANEL_ID, IOutputService, CONTEXT_IN_OUTPUT } from 'vs/workbench/parts/output/common/output';
import { SwitchOutputAction, SwitchOutputActionItem, ClearOutputAction, ToggleOutputScrollLockAction, OpenLogOutputFile } from 'vs/workbench/parts/output/browser/outputActions';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { CancellationToken } from 'vs/base/common/cancellation';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
export class OutputPanel extends AbstractTextResourceEditor {
private actions: IAction[];
......@@ -39,11 +39,11 @@ export class OutputPanel extends AbstractTextResourceEditor {
@IThemeService themeService: IThemeService,
@IOutputService private outputService: IOutputService,
@IContextKeyService private contextKeyService: IContextKeyService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@INextEditorGroupsService editorGroupService: INextEditorGroupsService,
@ITextFileService textFileService: ITextFileService,
@INextEditorGroupsService nextEditorGroupService: INextEditorGroupsService
@INextEditorService editorService: INextEditorService
) {
super(OUTPUT_PANEL_ID, telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorGroupService, textFileService, nextEditorGroupService);
super(OUTPUT_PANEL_ID, telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorGroupService, textFileService, editorService);
this.scopedInstantiationService = instantiationService;
}
......
......@@ -42,7 +42,6 @@ import { VSash } from 'vs/base/browser/ui/sash/sash';
import { Widget } from 'vs/base/browser/ui/widget';
import { IPreferencesRenderer, DefaultSettingsRenderer, UserSettingsRenderer, WorkspaceSettingsRenderer, FolderSettingsRenderer } from 'vs/workbench/parts/preferences/browser/preferencesRenderers';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
import { FoldingController } from 'vs/editor/contrib/folding/folding';
import { FindController } from 'vs/editor/contrib/find/findController';
......@@ -63,6 +62,7 @@ import { PreferencesEditorInput, DefaultPreferencesEditorInput } from 'vs/workbe
import { PREFERENCES_EDITOR_ID } from 'vs/workbench/parts/files/common/files';
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
import { CancellationToken } from 'vs/base/common/cancellation';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
export class PreferencesEditor extends BaseEditor {
......@@ -966,10 +966,10 @@ export class DefaultPreferencesEditor extends BaseTextEditor {
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
@IThemeService themeService: IThemeService,
@ITextFileService textFileService: ITextFileService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@INextEditorGroupsService nextEditorGroupService: INextEditorGroupsService
@INextEditorGroupsService editorGroupService: INextEditorGroupsService,
@INextEditorService editorService: INextEditorService
) {
super(DefaultPreferencesEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorGroupService, nextEditorGroupService);
super(DefaultPreferencesEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService);
}
private static _getContributions(): IEditorContributionCtor[] {
......
......@@ -15,18 +15,18 @@ import { IWorkbenchActionRegistry, Extensions as WorkbenchActionExtensions } fro
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
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';
class OpenSCMViewletAction extends ToggleViewletAction {
static readonly ID = VIEWLET_ID;
static LABEL = localize('toggleGitViewlet', "Show Git");
constructor(id: string, label: string, @IViewletService viewletService: IViewletService, @IWorkbenchEditorService editorService: IWorkbenchEditorService) {
constructor(id: string, label: string, @IViewletService viewletService: IViewletService, @INextEditorService editorService: INextEditorService) {
super(id, label, VIEWLET_ID, viewletService, editorService);
}
}
......@@ -87,4 +87,4 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
description: localize('diffGutterWidth', "Controls the width(px) of diff decorations in gutter (added & modified).")
}
}
});
\ No newline at end of file
});
......@@ -46,7 +46,6 @@ import URI from 'vs/base/common/uri';
import { relative } from 'path';
import { dirname } from 'vs/base/common/resources';
import { ResourceContextKey } from 'vs/workbench/common/resources';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IFileService } from 'vs/platform/files/common/files';
import { distinct } from 'vs/base/common/arrays';
import { getMultiSelectedResources } from 'vs/workbench/parts/files/browser/files';
......@@ -59,6 +58,7 @@ import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } fr
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { SearchViewLocationUpdater } from 'vs/workbench/parts/search/browser/searchViewLocationUpdater';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService';
registerSingleton(ISearchWorkbenchService, SearchWorkbenchService);
replaceContributions();
......@@ -337,7 +337,7 @@ CommandsRegistry.registerCommand({
const viewletService = accessor.get(IViewletService);
const panelService = accessor.get(IPanelService);
const fileService = accessor.get(IFileService);
const resources = getMultiSelectedResources(resource, listService, accessor.get(IWorkbenchEditorService));
const resources = getMultiSelectedResources(resource, listService, accessor.get(INextEditorService));
return openSearchView(viewletService, panelService, true).then(searchView => {
if (resources && resources.length) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册