diff --git a/src/vs/workbench/browser/parts/editor2/nextEditorActions.ts b/src/vs/workbench/browser/parts/editor2/nextEditorActions.ts index 2345f1f91c7a629f3d2a088166574ba97007b0b2..b3d1138da144683c99d938db16c31b8e7f558c39 100644 --- a/src/vs/workbench/browser/parts/editor2/nextEditorActions.ts +++ b/src/vs/workbench/browser/parts/editor2/nextEditorActions.ts @@ -14,7 +14,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi import { EditorInput } from 'vs/workbench/common/editor'; import { join, dirname } from 'vs/base/common/paths'; import { isWindows } from 'vs/base/common/platform'; -import { INextEditorService, SIDE_BY_SIDE } from 'vs/workbench/services/editor/common/nextEditorService'; +import { INextEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/nextEditorService'; function getVSCodeBaseFolder(): string { let workingDir = process.cwd(); @@ -138,7 +138,7 @@ export class GridOpenOneEditorSideBySideAction extends Action { run(): TPromise { const path = join(getVSCodeBaseFolder(), 'src/vs/workbench/browser/parts/editor/editor.contribution.ts'); - this.editorService.openEditor(this.legacyEditorService.createInput({ resource: URI.file(path) }) as EditorInput, null, SIDE_BY_SIDE); + this.editorService.openEditor(this.legacyEditorService.createInput({ resource: URI.file(path) }) as EditorInput, null, SIDE_GROUP); return TPromise.as(void 0); } diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index 543559821178ae3ecc2eedd42c31470ffafbb036..8c547da576841313077bd9a384da0329f55204b3 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -34,7 +34,6 @@ import { Event, Emitter } from 'vs/base/common/event'; import { IPartService } from 'vs/workbench/services/part/common/partService'; import { QuickOpenHandler, QuickOpenHandlerDescriptor, IQuickOpenRegistry, Extensions, EditorQuickOpenEntry, CLOSE_ON_FOCUS_LOST_CONFIG } from 'vs/workbench/browser/quickopen'; import * as errors from 'vs/base/common/errors'; -import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IPickOpenEntry, IFilePickOpenEntry, IQuickOpenService, IPickOptions, IShowOptions, IPickOpenItem } from 'vs/platform/quickOpen/common/quickOpen'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; @@ -56,6 +55,7 @@ import { Schemas } from 'vs/base/common/network'; import Severity from 'vs/base/common/severity'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { Dimension, addClass } from 'vs/base/browser/dom'; +import { INextEditorService, ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/editor/common/nextEditorService'; const HELP_PREFIX = '?'; @@ -101,7 +101,7 @@ export class QuickOpenController extends Component implements IQuickOpenService private editorHistoryHandler: EditorHistoryHandler; constructor( - @IWorkbenchEditorService private editorService: IWorkbenchEditorService, + @INextEditorService private editorService: INextEditorService, @INotificationService private notificationService: INotificationService, @IContextKeyService private contextKeyService: IContextKeyService, @IConfigurationService private configurationService: IConfigurationService, @@ -514,7 +514,7 @@ export class QuickOpenController extends Component implements IQuickOpenService if (!quickNavigateConfiguration) { autoFocus = { autoFocusFirstEntry: true }; } else { - const visibleEditorCount = this.editorService.getVisibleEditors().length; + const visibleEditorCount = this.editorService.visibleEditors.length; autoFocus = { autoFocusFirstEntry: visibleEditorCount === 0, autoFocusSecondEntry: visibleEditorCount !== 0 }; } } @@ -635,9 +635,9 @@ export class QuickOpenController extends Component implements IQuickOpenService private restoreFocus(): void { // Try to focus active editor - const editor = this.editorService.getActiveEditor(); - if (editor) { - editor.focus(); + const editorControl = this.editorService.activeControl; + if (editorControl) { + editorControl.focus(); } } @@ -1184,7 +1184,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry { constructor( input: IEditorInput | IResourceInput, - @IWorkbenchEditorService editorService: IWorkbenchEditorService, + @INextEditorService editorService: INextEditorService, @IModeService private modeService: IModeService, @IModelService private modelService: IModelService, @ITextFileService private textFileService: ITextFileService, @@ -1251,9 +1251,9 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry { const pinned = !this.configurationService.getValue().workbench.editor.enablePreviewFromQuickOpen || context.keymods.alt; if (this.input instanceof EditorInput) { - this.editorService.openEditor(this.input, { pinned }, sideBySide).done(null, errors.onUnexpectedError); + this.editorService.openEditor(this.input, { pinned }, sideBySide ? SIDE_GROUP : ACTIVE_GROUP); } else { - this.editorService.openEditor({ resource: (this.input as IResourceInput).resource, options: { pinned } }, sideBySide); + this.editorService.openEditor({ resource: (this.input as IResourceInput).resource, options: { pinned } }, sideBySide ? SIDE_GROUP : ACTIVE_GROUP); } return true; diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index 90637cb8ba55a4cf022624191c8e7510b7cafb5f..3a31643753a61ba7555fbcd6987e390e3b4d795f 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -10,16 +10,15 @@ import * as objects from 'vs/base/common/objects'; import * as arrays from 'vs/base/common/arrays'; import * as strings from 'vs/base/common/strings'; import * as types from 'vs/base/common/types'; -import * as errors from 'vs/base/common/errors'; import { Registry } from 'vs/platform/registry/common/platform'; import { Action } from 'vs/base/common/actions'; import { Mode, IEntryRunContext, IAutoFocus, IModel, IQuickNavigateConfiguration } from 'vs/base/parts/quickopen/common/quickOpen'; import { QuickOpenEntry, QuickOpenEntryGroup } from 'vs/base/parts/quickopen/browser/quickOpenModel'; import { EditorOptions, EditorInput } from 'vs/workbench/common/editor'; import { IResourceInput, IEditorInput, IEditorOptions } from 'vs/platform/editor/common/editor'; -import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { IConstructorSignature0, IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { INextEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/nextEditorService'; export const CLOSE_ON_FOCUS_LOST_CONFIG = 'workbench.quickOpen.closeOnFocusLost'; @@ -246,7 +245,7 @@ export interface IEditorQuickOpenEntry { */ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuickOpenEntry { - constructor(private _editorService: IWorkbenchEditorService) { + constructor(private _editorService: INextEditorService) { super(); } @@ -284,7 +283,7 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick opts = EditorOptions.create(openOptions); } - this.editorService.openEditor(input, opts, sideBySide).done(null, errors.onUnexpectedError); + this.editorService.openEditor(input, opts, sideBySide ? SIDE_GROUP : ACTIVE_GROUP); } else { const resourceInput = input; @@ -292,7 +291,7 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick resourceInput.options = objects.assign(resourceInput.options || Object.create(null), openOptions); } - this.editorService.openEditor(resourceInput, sideBySide).done(null, errors.onUnexpectedError); + this.editorService.openEditor(resourceInput, sideBySide ? SIDE_GROUP : ACTIVE_GROUP); } } diff --git a/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts b/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts index fd4abde0cb9d5ce8ae1e8538642ba47750186b9d..318cdaf563ff286c22f571cb08a052e47fb6148a 100644 --- a/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts +++ b/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts @@ -7,12 +7,11 @@ import { TPromise } from 'vs/base/common/winjs.base'; import * as nls from 'vs/nls'; import * as types from 'vs/base/common/types'; -import * as errors from 'vs/base/common/errors'; import { IEntryRunContext, Mode, IAutoFocus } from 'vs/base/parts/quickopen/common/quickOpen'; import { QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel'; import { QuickOpenHandler, EditorQuickOpenEntry, QuickOpenAction } from 'vs/workbench/browser/quickopen'; import { IEditor, IEditorViewState, IDiffEditorModel, ScrollType } from 'vs/editor/common/editorCommon'; -import { IModelDecorationsChangeAccessor, OverviewRulerLane, IModelDeltaDecoration, ITextModel } from 'vs/editor/common/model'; +import { OverviewRulerLane, IModelDeltaDecoration, ITextModel } from 'vs/editor/common/model'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { Position, IEditorInput, ITextEditorOptions } from 'vs/platform/editor/common/editor'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; @@ -21,6 +20,7 @@ import { IRange } from 'vs/editor/common/core/range'; import { overviewRulerRangeHighlight } from 'vs/editor/common/view/editorColorRegistry'; import { themeColorFromId } from 'vs/platform/theme/common/themeService'; import { IEditorOptions, RenderLineNumbersType } from 'vs/editor/common/config/editorOptions'; +import { INextEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/nextEditorService'; export const GOTO_LINE_PREFIX = ':'; @@ -75,7 +75,7 @@ class GotoLineEntry extends EditorQuickOpenEntry { private column: number; private handler: GotoLineHandler; - constructor(line: string, editorService: IWorkbenchEditorService, handler: GotoLineHandler) { + constructor(line: string, editorService: INextEditorService, handler: GotoLineHandler) { super(editorService); this.parseInput(line); @@ -109,9 +109,9 @@ class GotoLineEntry extends EditorQuickOpenEntry { } private getMaxLineNumber(): number { - const editor = this.editorService.getActiveEditor(); - const editorControl = editor.getControl(); - let model = editorControl.getModel(); + const codeEditor = this.editorService.activeTextEditorControl; + + let model = codeEditor.getModel(); if (model && (model).modified && (model).original) { model = (model).modified; // Support for diff editor models } @@ -128,7 +128,7 @@ class GotoLineEntry extends EditorQuickOpenEntry { } public getInput(): IEditorInput { - return this.editorService.getActiveEditorInput(); + return this.editorService.activeEditor; } public getOptions(pinned?: boolean): ITextEditorOptions { @@ -148,16 +148,15 @@ class GotoLineEntry extends EditorQuickOpenEntry { // Check for sideBySide use const sideBySide = context.keymods.ctrlCmd; if (sideBySide) { - this.editorService.openEditor(this.getInput(), this.getOptions(context.keymods.alt), true).done(null, errors.onUnexpectedError); + this.editorService.openEditor(this.getInput(), this.getOptions(context.keymods.alt), SIDE_GROUP); } // Apply selection and focus const range = this.toSelection(); - const activeEditor = this.editorService.getActiveEditor(); - if (activeEditor) { - const editor = activeEditor.getControl(); - editor.setSelection(range); - editor.revealRangeInCenter(range, ScrollType.Smooth); + const codeEditor = this.editorService.activeTextEditorControl; + if (codeEditor) { + codeEditor.setSelection(range); + codeEditor.revealRangeInCenter(range, ScrollType.Smooth); } return true; @@ -174,14 +173,13 @@ class GotoLineEntry extends EditorQuickOpenEntry { // Select Line Position const range = this.toSelection(); - const activeEditor = this.editorService.getActiveEditor(); - if (activeEditor) { - const editorControl = activeEditor.getControl(); - editorControl.revealRangeInCenter(range, ScrollType.Smooth); + const codeEditor = this.editorService.activeTextEditorControl; + if (codeEditor) { + codeEditor.revealRangeInCenter(range, ScrollType.Smooth); // Decorate if possible - if (types.isFunction(editorControl.changeDecorations)) { - this.handler.decorateOutline(range, editorControl, activeEditor.position); + if (types.isFunction(codeEditor.changeDecorations)) { + this.handler.decorateOutline(range, codeEditor, 0 /* TODO@grid activeEditor.position */); } } @@ -211,7 +209,7 @@ export class GotoLineHandler extends QuickOpenHandler { private rangeHighlightDecorationId: IEditorLineDecoration; private lastKnownEditorViewState: IEditorViewState; - constructor(@IWorkbenchEditorService private editorService: IWorkbenchEditorService) { + constructor(@INextEditorService private editorService: INextEditorService) { super(); } @@ -224,21 +222,21 @@ export class GotoLineHandler extends QuickOpenHandler { // Remember view state to be able to restore on cancel if (!this.lastKnownEditorViewState) { - const editor = this.editorService.getActiveEditor(); - this.lastKnownEditorViewState = (editor.getControl()).saveViewState(); + const codeEditor = this.editorService.activeTextEditorControl; + this.lastKnownEditorViewState = codeEditor.saveViewState(); } return TPromise.as(new QuickOpenModel([new GotoLineEntry(searchValue, this.editorService, this)])); } public canRun(): boolean | string { - const canRun = getCodeEditor(this.editorService.getActiveEditor()) !== null; + const canRun = !!this.editorService.activeTextEditorControl; return canRun ? true : nls.localize('cannotRunGotoLine', "Open a text file first to go to a line"); } public decorateOutline(range: IRange, editor: IEditor, position: Position): void { - editor.changeDecorations((changeAccessor: IModelDecorationsChangeAccessor) => { + editor.changeDecorations(changeAccessor => { const deleteDecorations: string[] = []; if (this.rangeHighlightDecorationId) { @@ -284,10 +282,10 @@ export class GotoLineHandler extends QuickOpenHandler { public clearDecorations(): void { if (this.rangeHighlightDecorationId) { - this.editorService.getVisibleEditors().forEach((editor) => { + this.editorService.visibleControls.forEach(editor => { if (editor.position === this.rangeHighlightDecorationId.position) { const editorControl = editor.getControl(); - editorControl.changeDecorations((changeAccessor: IModelDecorationsChangeAccessor) => { + editorControl.changeDecorations(changeAccessor => { changeAccessor.deltaDecorations([ this.rangeHighlightDecorationId.lineDecorationId, this.rangeHighlightDecorationId.rangeHighlightId @@ -307,10 +305,9 @@ export class GotoLineHandler extends QuickOpenHandler { // Restore selection if canceled if (canceled && this.lastKnownEditorViewState) { - const activeEditor = this.editorService.getActiveEditor(); - if (activeEditor) { - const editor = activeEditor.getControl(); - editor.restoreViewState(this.lastKnownEditorViewState); + const codeEditor = this.editorService.activeTextEditorControl; + if (codeEditor) { + codeEditor.restoreViewState(this.lastKnownEditorViewState); } } diff --git a/src/vs/workbench/parts/search/browser/openFileHandler.ts b/src/vs/workbench/parts/search/browser/openFileHandler.ts index 7fa00c00bb27426509d44f81e3a915ce96c51134..7a4de786be4f17ceb0138f9c47ea2ea50368fe4d 100644 --- a/src/vs/workbench/parts/search/browser/openFileHandler.ts +++ b/src/vs/workbench/parts/search/browser/openFileHandler.ts @@ -25,7 +25,6 @@ import { QueryBuilder } from 'vs/workbench/parts/search/common/queryBuilder'; import { EditorInput, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IResourceInput } from 'vs/platform/editor/common/editor'; -import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IQueryOptions, ISearchService, ISearchStats, ISearchQuery } from 'vs/platform/search/common/search'; @@ -33,6 +32,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IRange } from 'vs/editor/common/core/range'; import { getOutOfWorkspaceEditorResources } from 'vs/workbench/parts/search/common/search'; +import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService'; export class FileQuickOpenModel extends QuickOpenModel { @@ -49,7 +49,7 @@ export class FileEntry extends EditorQuickOpenEntry { private name: string, private description: string, private icon: string, - @IWorkbenchEditorService editorService: IWorkbenchEditorService, + @INextEditorService editorService: INextEditorService, @IModeService private modeService: IModeService, @IModelService private modelService: IModelService, @IConfigurationService private configurationService: IConfigurationService, diff --git a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts b/src/vs/workbench/parts/search/browser/openSymbolHandler.ts index a71f2e51e8be1db2884421bb90b20b26899c5904..044b7da5ce86f8bf994304628b9b4985d772ea11 100644 --- a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts +++ b/src/vs/workbench/parts/search/browser/openSymbolHandler.ts @@ -19,13 +19,13 @@ import { EditorInput, IWorkbenchEditorConfiguration } from 'vs/workbench/common/ import * as labels from 'vs/base/common/labels'; import { SymbolInformation, symbolKindToCssClass } from 'vs/editor/common/modes'; import { IResourceInput } from 'vs/platform/editor/common/editor'; -import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IWorkspaceSymbolProvider, getWorkspaceSymbols } from 'vs/workbench/parts/search/common/search'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { basename } from 'vs/base/common/paths'; +import { INextEditorService } from 'vs/workbench/services/editor/common/nextEditorService'; class SymbolEntry extends EditorQuickOpenEntry { @@ -36,7 +36,7 @@ class SymbolEntry extends EditorQuickOpenEntry { private _provider: IWorkspaceSymbolProvider, @IConfigurationService private readonly _configurationService: IConfigurationService, @IWorkspaceContextService private readonly _contextService: IWorkspaceContextService, - @IWorkbenchEditorService editorService: IWorkbenchEditorService, + @INextEditorService editorService: INextEditorService, @IEnvironmentService private readonly _environmentService: IEnvironmentService ) { super(editorService); diff --git a/src/vs/workbench/services/editor/browser/nextEditorService.ts b/src/vs/workbench/services/editor/browser/nextEditorService.ts index 3814c06ecb692991dea5f3a14096a557653791c2..262da78ed5396a54f84f5feb3e86f28a27ec26cb 100644 --- a/src/vs/workbench/services/editor/browser/nextEditorService.ts +++ b/src/vs/workbench/services/editor/browser/nextEditorService.ts @@ -25,7 +25,7 @@ import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; import { localize } from 'vs/nls'; import { TPromise } from 'vs/base/common/winjs.base'; import { INextEditorGroupsService, INextEditorGroup, GroupDirection } from 'vs/workbench/services/group/common/nextEditorGroupsService'; -import { INextEditorService, IResourceEditor, SIDE_BY_SIDE_TYPE, SIDE_BY_SIDE } from 'vs/workbench/services/editor/common/nextEditorService'; +import { INextEditorService, IResourceEditor, ACTIVE_GROUP_TYPE, SIDE_GROUP_TYPE, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/nextEditorService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle'; import { coalesce } from 'vs/base/common/arrays'; @@ -161,15 +161,19 @@ export class NextEditorService extends Disposable implements INextEditorService return coalesce(this.nextEditorGroupsService.groups.map(group => group.activeControl)); } + get visibleTextEditorControls(): ICodeEditor[] { + return this.visibleControls.map(control => control.getControl() as ICodeEditor).filter(widget => isCodeEditor(widget)); + } + get visibleEditors(): IEditorInput[] { return coalesce(this.nextEditorGroupsService.groups.map(group => group.activeEditor)); } //#region openEditor() - openEditor(editor: IEditorInput, options?: IEditorOptions, group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable; - openEditor(editor: IResourceEditor, group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable; - openEditor(editor: IEditorInput | IResourceEditor, optionsOrGroup?: IEditorOptions | GroupIdentifier, group?: GroupIdentifier): Thenable { + openEditor(editor: IEditorInput, options?: IEditorOptions, group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditor(editor: IResourceEditor, group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditor(editor: IEditorInput | IResourceEditor, optionsOrGroup?: IEditorOptions | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE, group?: GroupIdentifier): Thenable { // Typed Editor Support if (editor instanceof EditorInput) { @@ -201,11 +205,16 @@ export class NextEditorService extends Disposable implements INextEditorService return TPromise.wrap(null); } - private findTargetGroup(input: IEditorInput, options?: IEditorOptions, group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): INextEditorGroup { + private findTargetGroup(input: IEditorInput, options?: IEditorOptions, group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): INextEditorGroup { let targetGroup: INextEditorGroup; + // Group: Active Group + if (group === ACTIVE_GROUP) { + targetGroup = this.nextEditorGroupsService.activeGroup; + } + // Group: Side by Side - if (group === SIDE_BY_SIDE) { + else if (group === SIDE_GROUP) { targetGroup = this.createSideBySideGroup(); } @@ -270,9 +279,9 @@ export class NextEditorService extends Disposable implements INextEditorService //#region openEditors() - openEditors(editors: IEditorInputWithOptions[], group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable; - openEditors(editors: IResourceEditor[], group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable; - openEditors(editors: (IEditorInputWithOptions | IResourceEditor)[], group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable { + openEditors(editors: IEditorInputWithOptions[], group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditors(editors: IResourceEditor[], group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditors(editors: (IEditorInputWithOptions | IResourceEditor)[], group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable { // Convert to typed editors and options const typedEditors: IEditorInputWithOptions[] = []; @@ -286,7 +295,7 @@ export class NextEditorService extends Disposable implements INextEditorService // Find target groups to open const mapGroupToEditors = new Map(); - if (group === SIDE_BY_SIDE) { + if (group === SIDE_GROUP) { mapGroupToEditors.set(this.createSideBySideGroup(), typedEditors); } else { typedEditors.forEach(typedEditor => { diff --git a/src/vs/workbench/services/editor/common/nextEditorService.ts b/src/vs/workbench/services/editor/common/nextEditorService.ts index 1488ca2a20beb3b9f1d3578f900c27213dc64eb3..89cff8da61263cc7be2d859e36898729ecb6a82f 100644 --- a/src/vs/workbench/services/editor/common/nextEditorService.ts +++ b/src/vs/workbench/services/editor/common/nextEditorService.ts @@ -15,8 +15,11 @@ export const INextEditorService = createDecorator('nextEdito export type IResourceEditor = IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput; -export const SIDE_BY_SIDE = -1; -export type SIDE_BY_SIDE_TYPE = typeof SIDE_BY_SIDE; +export const ACTIVE_GROUP = -1; +export type ACTIVE_GROUP_TYPE = typeof ACTIVE_GROUP; + +export const SIDE_GROUP = -2; +export type SIDE_GROUP_TYPE = typeof SIDE_GROUP; export interface INextEditorService { _serviceBrand: ServiceIdentifier; @@ -68,6 +71,11 @@ export interface INextEditorService { */ readonly visibleControls: ReadonlyArray; + /** + * All text editor controls that are currently visible across all editor groups. + */ + readonly visibleTextEditorControls: ICodeEditor[]; + /** * All editors that are currently visible across all editor groups. */ @@ -79,31 +87,31 @@ export interface INextEditorService { * @param editor the editor to open * @param options the options to use for the editor * @param group the target group. If unspecified, the editor will open in the currently - * active group. Use `SIDE_BY_SIDE` to open the editor in a new editor group to the side + * active group. Use `SIDE_GROUP_TYPE` to open the editor in a new editor group to the side * of the currently active group. */ - openEditor(editor: IEditorInput, options?: IEditorOptions, group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable; + openEditor(editor: IEditorInput, options?: IEditorOptions, group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; /** * Open an editor in an editor group. * * @param editor the editor to open * @param group the target group. If unspecified, the editor will open in the currently - * active group. Use `SIDE_BY_SIDE` to open the editor in a new editor group to the side + * active group. Use `SIDE_GROUP_TYPE` to open the editor in a new editor group to the side * of the currently active group. */ - openEditor(editor: IResourceEditor, group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable; + openEditor(editor: IResourceEditor, group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; /** * Open editors in an editor group. * * @param editors the editors to open with associated options * @param group the target group. If unspecified, the editor will open in the currently - * active group. Use `SIDE_BY_SIDE` to open the editor in a new editor group to the side + * active group. Use `SIDE_GROUP_TYPE` to open the editor in a new editor group to the side * of the currently active group. */ - openEditors(editors: IEditorInputWithOptions[], group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable; - openEditors(editors: IResourceEditor[], group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable; + openEditors(editors: IEditorInputWithOptions[], group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditors(editors: IResourceEditor[], group?: GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; /** * Find out if the provided editor (or resource of an editor) is opened in any group.