提交 01bf9616 编写于 作者: B Benjamin Pasero

grid - towards GroupIdentifier over Position in IEditor

上级 b0cd4967
......@@ -10,7 +10,7 @@ import URI from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { IConfigurationService, IConfigurationChangeEvent, IConfigurationOverrides, IConfigurationData } from 'vs/platform/configuration/common/configuration';
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IEditor, IEditorInput, IEditorOptions, IEditorService, IResourceInput, Position } from 'vs/platform/editor/common/editor';
import { IEditor, IEditorInput, IEditorOptions, IEditorService, IResourceInput, GroupIdentifier } from 'vs/platform/editor/common/editor';
import { ICommandService, ICommand, ICommandEvent, ICommandHandler, CommandsRegistry } from 'vs/platform/commands/common/commands';
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding';
......@@ -52,7 +52,7 @@ export class SimpleEditor implements IEditor {
public input: IEditorInput;
public options: IEditorOptions;
public position: Position;
public group: GroupIdentifier;
public _widget: editorCommon.IEditor;
......
......@@ -24,6 +24,9 @@ export interface IEditorService {
export interface IEditorModel {
/**
* Emitted when the model is disposed.
*/
onDispose: Event<void>;
/**
......@@ -122,9 +125,12 @@ export interface IResourceSideBySideInput extends IBaseResourceInput {
detailResource: URI;
}
export interface IEditorControl {
/**
* Marker interface for the editor control
*/
export interface IEditorControl { }
}
export type GroupIdentifier = number;
export interface IEditor {
......@@ -139,9 +145,9 @@ export interface IEditor {
options: IEditorOptions;
/**
* The assigned position of this editor.
* The assigned group this editor is showing in.
*/
position: Position;
group: GroupIdentifier;
/**
* Returns the unique identifier of this editor.
......
......@@ -422,14 +422,14 @@ export class MainThreadDocumentsAndEditors {
options: props.options,
selections: props.selections,
visibleRanges: props.visibleRanges,
editorPosition: this._findEditorPosition(textEditor)
editorPosition: this._findEditorPosition(textEditor) // TODO@grid [EXTENSIONS] adopt in extension host
};
}
private _findEditorPosition(editor: MainThreadTextEditor): EditorPosition {
for (let workbenchEditor of this._workbenchEditorService.getVisibleEditors()) {
if (editor.matches(workbenchEditor)) {
return workbenchEditor.position;
return workbenchEditor.group;
}
}
return undefined;
......
......@@ -99,7 +99,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
for (let workbenchEditor of this._workbenchEditorService.getVisibleEditors()) {
const id = this._documentsAndEditors.findTextEditorIdFor(workbenchEditor);
if (id) {
result[id] = workbenchEditor.position;
result[id] = workbenchEditor.group; // TODO@grid [EXTENSIONS] adopt in extension host
}
}
return result;
......@@ -147,7 +147,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
let editors = this._workbenchEditorService.getVisibleEditors();
for (let editor of editors) {
if (mainThreadEditor.matches(editor)) {
return this._workbenchEditorService.closeEditor(editor.position, editor.input).then(() => { return; });
return this._workbenchEditorService.closeEditor(editor.group, editor.input).then(() => { return; });
}
}
}
......
......@@ -136,7 +136,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
this._webviews.set(handle, webview);
webview._events = this.createWebviewEventDelegate(handle);
return this._proxy.$deserializeWebviewPanel(handle, webview.state.viewType, webview.getTitle(), webview.state.state, webview.position, webview.options)
return this._proxy.$deserializeWebviewPanel(handle, webview.state.viewType, webview.getTitle(), webview.state.state, webview.group, webview.options) // TODO@grid [EXTENSIONS] adopt group identifier
.then(undefined, () => {
webview.html = MainThreadWebviews.getDeserializationFailedContents(viewType);
});
......@@ -217,7 +217,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
if (newActiveWebview && newActiveWebview.handle === this._activeWebview) {
// Webview itself unchanged but position may have changed
this._proxy.$onDidChangeWebviewPanelViewState(newActiveWebview.handle, true, newActiveWebview.input.position);
this._proxy.$onDidChangeWebviewPanelViewState(newActiveWebview.handle, true, newActiveWebview.input.group); // TODO@grid [EXTENSIONS] adopt group identifier
return;
}
......@@ -225,13 +225,13 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
if (typeof this._activeWebview !== 'undefined') {
const oldActiveWebview = this._webviews.get(this._activeWebview);
if (oldActiveWebview) {
this._proxy.$onDidChangeWebviewPanelViewState(this._activeWebview, false, oldActiveWebview.position);
this._proxy.$onDidChangeWebviewPanelViewState(this._activeWebview, false, oldActiveWebview.group); // TODO@grid [EXTENSIONS] adopt group identifier
}
}
// Then for newly active
if (newActiveWebview) {
this._proxy.$onDidChangeWebviewPanelViewState(newActiveWebview.handle, true, activeEditor.position);
this._proxy.$onDidChangeWebviewPanelViewState(newActiveWebview.handle, true, activeEditor.group); // TODO@grid [EXTENSIONS] adopt in extension host
this._activeWebview = newActiveWebview.handle;
} else {
this._activeWebview = undefined;
......@@ -245,9 +245,9 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
}
this._webviews.forEach((input, handle) => {
if (workbenchEditor.input.matches(input) && input.position !== workbenchEditor.position) {
input.updatePosition(workbenchEditor.position);
this._proxy.$onDidChangeWebviewPanelViewState(handle, handle === this._activeWebview, workbenchEditor.position);
if (workbenchEditor.input.matches(input) && input.group !== workbenchEditor.group) { // TODO@grid [EXTENSIONS] adopt group identifier
input.updateGroup(workbenchEditor.group);
this._proxy.$onDidChangeWebviewPanelViewState(handle, handle === this._activeWebview, workbenchEditor.group);
}
});
}
......
......@@ -6,16 +6,17 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { Panel } from 'vs/workbench/browser/panel';
import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
import { IEditor, Position } from 'vs/platform/editor/common/editor';
import { EditorInput, EditorOptions, GroupIdentifier } from 'vs/workbench/common/editor';
import { IEditor } from 'vs/platform/editor/common/editor';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
/**
* The base class of editors in the workbench. Editors register themselves for specific editor inputs.
* Editors are layed out in the editor part of the workbench. Only one editor can be open at a time.
* Each editor has a minimized representation that is good enough to provide some information about the
* state of the editor data.
* Editors are layed out in the editor part of the workbench in editor groups. Multiple editors can be
* open at the same time. Each editor has a minimized representation that is good enough to provide some
* information about the state of the editor data.
*
* The workbench will keep an editor alive after it has been created and show/hide it based on
* user interaction. The lifecycle of a editor goes in the order create(), setVisible(true|false),
* layout(), setInput(), focus(), dispose(). During use of the workbench, a editor will often receive a
......@@ -24,22 +25,32 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
* This class is only intended to be subclassed and not instantiated.
*/
export abstract class BaseEditor extends Panel implements IEditor {
protected _input: EditorInput;
private _options: EditorOptions;
private _position: Position; // TODO@grid change to GroupIdentifier and revisit if methods make sense (changePosition, setVisible, etc.)
private _group: GroupIdentifier;
constructor(id: string, telemetryService: ITelemetryService, themeService: IThemeService) {
constructor(
id: string,
telemetryService: ITelemetryService,
themeService: IThemeService
) {
super(id, telemetryService, themeService);
}
public get input(): EditorInput {
get input(): EditorInput {
return this._input;
}
public get options(): EditorOptions {
get options(): EditorOptions {
return this._options;
}
get group(): GroupIdentifier {
return this._group;
}
/**
* Note: Clients should not call this method, the workbench calls this
* method. Calling it otherwise may result in unexpected behavior.
......@@ -47,7 +58,7 @@ export abstract class BaseEditor extends Panel implements IEditor {
* Sets the given input with the options to the part. An editor has to deal with the
* situation that the same input is being set with different options.
*/
public setInput(input: EditorInput, options?: EditorOptions): TPromise<void> {
setInput(input: EditorInput, options?: EditorOptions): TPromise<void> {
this._input = input;
this._options = options;
......@@ -55,17 +66,17 @@ export abstract class BaseEditor extends Panel implements IEditor {
}
/**
* Called to indicate to the editor that the input should be cleared and resources associated with the
* input should be freed.
* Called to indicate to the editor that the input should be cleared and
* resources associated with the input should be freed.
*/
public clearInput(): void {
clearInput(): void {
this._input = null;
this._options = null;
}
public create(parent: HTMLElement): void; // create is sync for editors
public create(parent: HTMLElement): TPromise<void>;
public create(parent: HTMLElement): TPromise<void> {
create(parent: HTMLElement): void; // create is sync for editors
create(parent: HTMLElement): TPromise<void>;
create(parent: HTMLElement): TPromise<void> {
const res = super.create(parent);
// Create Editor
......@@ -79,46 +90,37 @@ export abstract class BaseEditor extends Panel implements IEditor {
*/
protected abstract createEditor(parent: HTMLElement): void;
/**
* Subclasses can set this to false if it does not make sense to center editor input.
*/
public supportsCenteredLayout(): boolean {
return true;
}
/**
* Overload this function to allow for passing in a position argument.
*/
public setVisible(visible: boolean, position?: Position): void; // setVisible is sync for editors
public setVisible(visible: boolean, position?: Position): TPromise<void>;
public setVisible(visible: boolean, position: Position = null): TPromise<void> {
setVisible(visible: boolean, group?: GroupIdentifier): void; // setVisible is sync for editors
setVisible(visible: boolean, group?: GroupIdentifier): TPromise<void>;
setVisible(visible: boolean, group?: GroupIdentifier): TPromise<void> {
const promise = super.setVisible(visible);
// Propagate to Editor
this.setEditorVisible(visible, position);
this.setEditorVisible(visible, group);
return promise;
}
protected setEditorVisible(visible: boolean, position: Position = null): void {
this._position = position;
}
/**
* Called when the position of the editor changes while it is visible.
* Indicates that the editor control got visible or hidden in a specific group. A
* editor instance will only ever be visible in one editor group.
*
* @param visible the state of visibility of this editor
* @param group the identifier of the editor group this editor is currently
* positioned.
*/
public changePosition(position: Position): void {
this._position = position;
protected setEditorVisible(visible: boolean, group: GroupIdentifier): void {
this._group = group;
}
/**
* The position this editor is showing in or null if none.
* Subclasses can set this to false if it does not make sense to center editor input.
*/
public get position(): Position {
return this._position;
supportsCenteredLayout(): boolean {
return true;
}
public dispose(): void {
dispose(): void {
this._input = null;
this._options = null;
......
......@@ -87,12 +87,12 @@ export class SplitEditorAction extends Action {
case 2:
// Continue splitting to the right/bottom
if (editorToSplit.position === Position.TWO) {
if (editorToSplit.group === Position.TWO) {
targetPosition = Position.THREE;
}
// Push the second group to the right/bottom to make room for the splitted input
else if (editorToSplit.position === Position.ONE) {
else if (editorToSplit.group === Position.ONE) {
options.preserveFocus = true;
return this.editorService.openEditor(editorToSplit.input, options, Position.THREE).then(() => {
......@@ -300,7 +300,7 @@ export class NavigateBetweenGroupsAction extends Action {
// Cycle to the left/top and use module to start at 0 again
const visibleEditors = this.editorService.getVisibleEditors();
const editorCount = visibleEditors.length;
const newIndex = (activeEditor.position + 1) % editorCount;
const newIndex = (activeEditor.group + 1) % editorCount;
this.editorGroupService.focusGroup(<Position>newIndex);
......@@ -351,7 +351,7 @@ export class FocusFirstGroupAction extends Action {
// Find left/top editor and focus it
const editors = this.editorService.getVisibleEditors();
for (let editor of editors) {
if (editor.position === Position.ONE) {
if (editor.group === Position.ONE) {
this.editorGroupService.focusGroup(Position.ONE);
return TPromise.as(true);
......@@ -398,14 +398,14 @@ export abstract class BaseFocusSideGroupAction extends Action {
const editor = editors[i];
// Target editor exists so focus it
if (editor.position === this.getTargetEditorSide()) {
this.editorGroupService.focusGroup(editor.position);
if (editor.group === this.getTargetEditorSide()) {
this.editorGroupService.focusGroup(editor.group);
return TPromise.as(true);
}
// Remember reference editor
if (editor.position === this.getReferenceEditorSide()) {
if (editor.group === this.getReferenceEditorSide()) {
referenceEditor = editor;
}
}
......@@ -522,7 +522,7 @@ export class FocusPreviousGroup extends Action {
}
// Nevigate to the previous group or to the last group if the first group is active
const newPositionIndex = (activeEditor.position + groupCount - 1) % groupCount;
const newPositionIndex = (activeEditor.group + groupCount - 1) % groupCount;
this.editorGroupService.focusGroup(<Position>newPositionIndex);
return TPromise.as(true);
......@@ -560,7 +560,7 @@ export class FocusNextGroup extends Action {
}
// Nevigate to the next group or to the first group if the last group is active
const newPositionIndex = (activeEditor.position + 1) % groupCount;
const newPositionIndex = (activeEditor.group + 1) % groupCount;
this.editorGroupService.focusGroup(<Position>newPositionIndex);
return TPromise.as(true);
......@@ -590,7 +590,7 @@ export class OpenToSideAction extends Action {
private updateEnablement(): void {
const activeEditor = this.editorService.getActiveEditor();
this.enabled = (!activeEditor || activeEditor.position !== Position.THREE);
this.enabled = (!activeEditor || activeEditor.group !== Position.THREE);
}
public run(context: any): TPromise<any> {
......@@ -709,7 +709,7 @@ export class RevertAndCloseEditorAction extends Action {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && activeEditor.input) {
const input = activeEditor.input;
const position = activeEditor.position;
const position = activeEditor.group;
// first try a normal revert where the contents of the editor are restored
return activeEditor.input.revert().then(() => this.editorService.closeEditor(position, input), error => {
......@@ -813,7 +813,7 @@ export class CloseEditorsInOtherGroupsAction extends Action {
if (typeof position !== 'number') {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor) {
position = activeEditor.position;
position = activeEditor.group;
}
}
......@@ -843,8 +843,8 @@ export class MoveGroupLeftAction extends Action {
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(context.group) : null;
if (typeof position !== 'number') {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && (activeEditor.position === Position.TWO || activeEditor.position === Position.THREE)) {
position = activeEditor.position;
if (activeEditor && (activeEditor.group === Position.TWO || activeEditor.group === Position.THREE)) {
position = activeEditor.group;
}
}
......@@ -879,8 +879,8 @@ export class MoveGroupRightAction extends Action {
const activeEditor = this.editorService.getActiveEditor();
const editors = this.editorService.getVisibleEditors();
if ((editors.length === 2 && activeEditor.position === Position.ONE) || (editors.length === 3 && activeEditor.position !== Position.THREE)) {
position = activeEditor.position;
if ((editors.length === 2 && activeEditor.group === Position.ONE) || (editors.length === 3 && activeEditor.group !== Position.THREE)) {
position = activeEditor.group;
}
}
......@@ -960,7 +960,7 @@ function getTarget(editorService: IWorkbenchEditorService, editorGroupService: I
const activeEditor = editorService.getActiveEditor();
if (activeEditor) {
return { input: activeEditor.input, position: activeEditor.position };
return { input: activeEditor.input, position: activeEditor.group };
}
return null;
......@@ -1390,7 +1390,7 @@ export class FocusLastEditorInStackAction extends Action {
public run(): TPromise<any> {
const active = this.editorService.getActiveEditor();
if (active) {
const group = this.editorGroupService.getStacksModel().groupAt(active.position);
const group = this.editorGroupService.getStacksModel().groupAt(active.group);
const editor = group.getEditor(group.count - 1);
if (editor) {
......@@ -1464,8 +1464,8 @@ export class MoveEditorToPreviousGroupAction extends Action {
public run(): TPromise<any> {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && activeEditor.position !== Position.ONE) {
this.editorGroupService.moveEditor(activeEditor.input, activeEditor.position, activeEditor.position - 1);
if (activeEditor && activeEditor.group !== Position.ONE) {
this.editorGroupService.moveEditor(activeEditor.input, activeEditor.group, activeEditor.group - 1);
}
return TPromise.as(true);
......@@ -1488,8 +1488,8 @@ export class MoveEditorToNextGroupAction extends Action {
public run(): TPromise<any> {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && activeEditor.position !== Position.THREE) {
this.editorGroupService.moveEditor(activeEditor.input, activeEditor.position, activeEditor.position + 1);
if (activeEditor && activeEditor.group !== Position.THREE) {
this.editorGroupService.moveEditor(activeEditor.input, activeEditor.group, activeEditor.group + 1);
}
return TPromise.as(true);
......@@ -1510,8 +1510,8 @@ export abstract class MoveEditorToSpecificGroup extends Action {
public run(): TPromise<any> {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && activeEditor.position !== this.position) {
this.editorGroupService.moveEditor(activeEditor.input, activeEditor.position, this.position);
if (activeEditor && activeEditor.group !== this.position) {
this.editorGroupService.moveEditor(activeEditor.input, activeEditor.group, this.position);
}
return TPromise.as(true);
......
......@@ -107,7 +107,7 @@ function moveActiveEditor(args: ActiveEditorMoveArguments = {}, accessor: Servic
function moveActiveTab(args: ActiveEditorMoveArguments, activeEditor: IEditor, accessor: ServicesAccessor): void {
const editorGroupsService: IEditorGroupService = accessor.get(IEditorGroupService);
const editorGroup = editorGroupsService.getStacksModel().groupAt(activeEditor.position);
const editorGroup = editorGroupsService.getStacksModel().groupAt(activeEditor.group);
let index = editorGroup.indexOf(activeEditor.input);
switch (args.to) {
case ActiveEditorMovePositioning.FIRST:
......@@ -135,7 +135,7 @@ function moveActiveTab(args: ActiveEditorMoveArguments, activeEditor: IEditor, a
}
function moveActiveEditorToGroup(args: ActiveEditorMoveArguments, activeEditor: IEditor, accessor: ServicesAccessor): void {
let newPosition = activeEditor.position;
let newPosition = activeEditor.group;
switch (args.to) {
case ActiveEditorMovePositioning.LEFT:
newPosition = newPosition - 1;
......@@ -157,8 +157,8 @@ function moveActiveEditorToGroup(args: ActiveEditorMoveArguments, activeEditor:
break;
}
newPosition = POSITIONS.indexOf(newPosition) !== -1 ? newPosition : activeEditor.position;
accessor.get(IEditorGroupService).moveEditor(activeEditor.input, activeEditor.position, newPosition);
newPosition = POSITIONS.indexOf(newPosition) !== -1 ? newPosition : activeEditor.group;
accessor.get(IEditorGroupService).moveEditor(activeEditor.input, activeEditor.group, newPosition);
}
function registerDiffEditorCommands(): void {
......@@ -234,7 +234,7 @@ function registerOpenEditorAtIndexCommands(): void {
const active = editorService.getActiveEditor();
if (active) {
const group = editorGroupService.getStacksModel().groupAt(active.position);
const group = editorGroupService.getStacksModel().groupAt(active.group);
const editor = group.getEditor(editorIndex);
if (editor) {
......@@ -314,7 +314,7 @@ function registerEditorCommands() {
}
const activeEditor = editorService.getActiveEditor();
if (activeEditor) {
return editorService.closeEditors(activeEditor.position);
return editorService.closeEditors(activeEditor.group);
}
return TPromise.as(false);
......@@ -526,7 +526,7 @@ function positionAndInput(editorGroupService: IEditorGroupService, editorService
// If position or input are not passed in take the position and input of the active editor.
const active = editorService.getActiveEditor();
if (active) {
position = typeof position === 'number' ? position : active.position;
position = typeof position === 'number' ? position : active.group;
input = input ? input : <EditorInput>active.input;
}
......
......@@ -685,7 +685,7 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
// Inform editor
const editor = this.visibleEditors[from];
editor.changePosition(to);
// editor.changePosition(to);
// Change data structures
const listeners = this.visibleEditorFocusTrackerDisposable[from];
......@@ -718,8 +718,8 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
containerTo.appendTo(this.silos[from]);
// Inform Editors
this.visibleEditors[from].changePosition(to);
this.visibleEditors[to].changePosition(from);
// this.visibleEditors[from].changePosition(to);
// this.visibleEditors[to].changePosition(from);
// Update last active position accordingly
if (this.lastActivePosition === from) {
......@@ -758,9 +758,9 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
containerPos3.appendTo(this.silos[newPositionThree]);
// Inform Editors
this.visibleEditors[Position.ONE].changePosition(newPositionOne);
this.visibleEditors[Position.TWO].changePosition(newPositionTwo);
this.visibleEditors[Position.THREE].changePosition(newPositionThree);
// this.visibleEditors[Position.ONE].changePosition(newPositionOne);
// this.visibleEditors[Position.TWO].changePosition(newPositionTwo);
// this.visibleEditors[Position.THREE].changePosition(newPositionThree);
// Update last active position accordingly
if (this.lastActivePosition === Position.ONE) {
......@@ -1135,7 +1135,7 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
let options = EditorOptions.create({ pinned: true });
const activeEditor = $this.editorService.getActiveEditor();
const editor = getCodeEditor(activeEditor);
if (editor && activeEditor.position === stacks.positionOfGroup(identifier.group) && identifier.editor.matches(activeEditor.input)) {
if (editor && activeEditor.group === stacks.positionOfGroup(identifier.group) && identifier.editor.matches(activeEditor.input)) {
options = TextEditorOptions.fromEditor(editor, { pinned: true });
}
......
......@@ -639,7 +639,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return activeEditorControl.invokeWithinContext(fn);
}
return this.editorGroupsControl.getInstantiationService(activeEditor.position).invokeFunction(fn);
return this.editorGroupsControl.getInstantiationService(activeEditor.group).invokeFunction(fn);
}
return this.instantiationService.invokeFunction(fn);
......@@ -759,7 +759,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
let options = EditorOptions.create({ pinned: true, index, inactive, preserveFocus });
const activeEditor = this.getActiveEditor();
const codeEditor = getCodeEditor(activeEditor);
if (codeEditor && activeEditor.position === this.stacks.positionOfGroup(fromGroup) && input.matches(activeEditor.input)) {
if (codeEditor && activeEditor.group === this.stacks.positionOfGroup(fromGroup) && input.matches(activeEditor.input)) {
options = TextEditorOptions.fromEditor(codeEditor, { pinned: true, index, inactive, preserveFocus });
}
......@@ -1612,7 +1612,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
// Position is sideBySide: Find position relative to active editor
if (arg1 === true) {
switch (activeEditor.position) {
switch (activeEditor.group) {
case Position.ONE:
return Position.TWO;
case Position.TWO:
......
......@@ -8,7 +8,7 @@ import * as DOM from 'vs/base/browser/dom';
import { Registry } from 'vs/platform/registry/common/platform';
import { EditorInput, EditorOptions, SideBySideEditorInput } from 'vs/workbench/common/editor';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { IEditorControl, Position, IEditor } from 'vs/platform/editor/common/editor';
import { IEditorControl, IEditor, GroupIdentifier } from 'vs/platform/editor/common/editor';
import { VSash } from 'vs/base/browser/ui/sash/sash';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
......@@ -49,24 +49,14 @@ export class SideBySideEditor extends BaseEditor {
.then(() => this.updateInput(oldInput, newInput, options));
}
protected setEditorVisible(visible: boolean, position: Position): void {
protected setEditorVisible(visible: boolean, group: GroupIdentifier): void {
if (this.masterEditor) {
this.masterEditor.setVisible(visible, position);
this.masterEditor.setVisible(visible, group);
}
if (this.detailsEditor) {
this.detailsEditor.setVisible(visible, position);
this.detailsEditor.setVisible(visible, group);
}
super.setEditorVisible(visible, position);
}
public changePosition(position: Position): void {
if (this.masterEditor) {
this.masterEditor.changePosition(position);
}
if (this.detailsEditor) {
this.detailsEditor.changePosition(position);
}
super.changePosition(position);
super.setEditorVisible(visible, group);
}
public clearInput(): void {
......@@ -138,7 +128,7 @@ export class SideBySideEditor extends BaseEditor {
const editor = descriptor.instantiate(this.instantiationService);
editor.create(container);
editor.setVisible(this.isVisible(), this.position);
editor.setVisible(this.isVisible(), this.group);
return editor;
}
......
......@@ -96,7 +96,7 @@ export class TextDiffEditor extends BaseTextEditor {
delegatingEditorService.setEditorOpenHandler((group: INextEditorGroup, input: EditorInput, options?: EditorOptions) => {
// Check if target group is same as this editor ones
if (group.id === this.position) {
if (group.id === this.group) {
const activeDiffInput = <DiffEditorInput>this.input;
if (input && options && activeDiffInput) {
......@@ -245,7 +245,7 @@ export class TextDiffEditor extends BaseTextEditor {
modifiedInput.setForceOpenAsBinary();
}
this.editorService.openEditor(binaryDiffInput, options, this.position).done(null, onUnexpectedError);
this.editorService.openEditor(binaryDiffInput, options, this.group).done(null, onUnexpectedError);
return true;
}
......
......@@ -13,10 +13,9 @@ import * as types from 'vs/base/common/types';
import * as errors from 'vs/base/common/errors';
import * as DOM from 'vs/base/browser/dom';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
import { EditorInput, EditorOptions, EditorViewStateMemento } from 'vs/workbench/common/editor';
import { EditorInput, EditorOptions, EditorViewStateMemento, GroupIdentifier } from 'vs/workbench/common/editor';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { IEditorViewState, IEditor } from 'vs/editor/common/editorCommon';
import { Position } from 'vs/platform/editor/common/editor';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
......@@ -107,8 +106,8 @@ export abstract class BaseTextEditor extends BaseEditor {
let ariaLabel = this.getAriaLabel();
// Apply group information to help identify in which group we are
if (ariaLabel && typeof this.position === 'number') {
ariaLabel = nls.localize('editorLabelWithGroup', "{0}, Group {1}.", ariaLabel, this.position + 1);
if (ariaLabel && typeof this.group === 'number') {
ariaLabel = nls.localize('editorLabelWithGroup', "{0}, Group {1}.", ariaLabel, this.group + 1);
}
return ariaLabel;
......@@ -195,16 +194,7 @@ export abstract class BaseTextEditor extends BaseEditor {
});
}
public changePosition(position: Position): void {
super.changePosition(position);
// Make sure to update ARIA label if the position of this editor changed
if (this.editorControl) {
this.editorControl.updateOptions({ ariaLabel: this.computeAriaLabel() });
}
}
protected setEditorVisible(visible: boolean, position: Position = null): void {
protected setEditorVisible(visible: boolean, group: GroupIdentifier): void {
// Pass on to Editor
if (visible) {
......@@ -214,7 +204,7 @@ export abstract class BaseTextEditor extends BaseEditor {
this.editorControl.onHide();
}
super.setEditorVisible(visible, position);
super.setEditorVisible(visible, group);
}
public focus(): void {
......@@ -240,7 +230,7 @@ export abstract class BaseTextEditor extends BaseEditor {
return;
}
this.editorViewStateMemento.saveState(resource, this.position, editorViewState);
this.editorViewStateMemento.saveState(resource, this.group, editorViewState);
}
protected retrieveTextEditorViewState(resource: URI): IEditorViewState {
......@@ -279,7 +269,7 @@ export abstract class BaseTextEditor extends BaseEditor {
* Loads the text editor view state for the given resource and returns it.
*/
protected loadTextEditorViewState(resource: URI): IEditorViewState {
return this.editorViewStateMemento.loadState(resource, this.position);
return this.editorViewStateMemento.loadState(resource, this.group);
}
private updateEditorConfiguration(configuration = this.configurationService.getValue<IEditorConfiguration>(this.getResource())): void {
......
......@@ -75,7 +75,7 @@ export class NextEditorControl extends Disposable {
show(control.getContainer());
// Indicate to editor that it is now visible
control.setVisible(true, this.groupId /* TODO@grid use group id instead of position */);
control.setVisible(true, this.groupId);
// Layout
if (this.dimension) {
......@@ -159,7 +159,7 @@ export class NextEditorControl extends Disposable {
// Indicate to editor control
this._activeControl.clearInput();
this._activeControl.setVisible(false);
this._activeControl.setVisible(false, this.groupId);
// Clear active control
this._activeControl = null;
......
......@@ -511,7 +511,7 @@ export class ElectronWindow extends Themable {
return this.editorService.openEditors(resources.map((r, index) => {
return {
input: r,
position: activeEditor ? activeEditor.position : Position.ONE
position: activeEditor ? activeEditor.group : Position.ONE
};
}));
});
......
......@@ -38,7 +38,6 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { Position } from 'vs/platform/editor/common/editor';
import { IPartService, Parts } from 'vs/workbench/services/part/common/partService';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { KeybindingLabel } from 'vs/base/browser/ui/keybindingLabel/keybindingLabel';
......@@ -380,11 +379,6 @@ export class ExtensionEditor extends BaseEditor {
return super.setInput(input, options);
}
changePosition(position: Position): void {
this.navbar.update();
super.changePosition(position);
}
showFind(): void {
if (this.activeWebview) {
this.activeWebview.showFind();
......
......@@ -489,7 +489,7 @@ export class ExtensionsListView extends ViewsViewletPanel {
const activeEditor = this.editorService.getActiveEditor();
const activeEditorInput = this.editorService.getActiveEditorInput();
this.editorInputService.pinEditor(activeEditor.position, activeEditorInput);
this.editorInputService.pinEditor(activeEditor.group, activeEditorInput);
activeEditor.focus();
}
......
......@@ -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.position).done(null, onUnexpectedError);
this.editorService.openEditor(input, options, this.group).done(null, onUnexpectedError);
}
}
......
......@@ -275,7 +275,7 @@ export class FileEditorTracker implements IWorkbenchContribution {
for (let i = 0; i < editors.length; i++) {
const editor = editors[i];
if (editor && editor.input && editor.position === stacks.positionOfGroup(group)) {
if (editor && editor.input && editor.group === stacks.positionOfGroup(group)) {
const editorResource = editor.input.getResource();
if (editorResource && resource.toString() === editorResource.toString()) {
const control = editor.getControl();
......@@ -313,7 +313,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.position).done(null, errors.onUnexpectedError);
this.editorService.openEditor(editor.input, { forceOpen: true, preserveFocus: true }, editor.group).done(null, errors.onUnexpectedError);
}
});
}
......
......@@ -71,7 +71,7 @@ export class TextFileEditor extends BaseTextEditor {
}
private onWillCloseEditor(e: IEditorCloseEvent): void {
if (e.editor === this.input && this.position === this.editorGroupService.getStacksModel().positionOfGroup(e.group)) {
if (e.editor === this.input && this.group === this.editorGroupService.getStacksModel().positionOfGroup(e.group)) {
this.doSaveTextEditorViewState(this.input);
}
}
......@@ -201,13 +201,13 @@ export class TextFileEditor extends BaseTextEditor {
private openAsBinary(input: FileEditorInput, options: EditorOptions): void {
input.setForceOpenAsBinary();
this.editorService.openEditor(input, options, this.position).done(null, errors.onUnexpectedError);
this.editorService.openEditor(input, options, this.group).done(null, errors.onUnexpectedError);
}
private openAsFolder(input: FileEditorInput): boolean {
// Since we cannot open a folder, we have to restore the previous input if any and close the editor
this.editorService.closeEditor(this.position, this.input).done(() => {
this.editorService.closeEditor(this.group, this.input).done(() => {
// Best we can do is to reveal the folder in the explorer
if (this.contextService.isInsideWorkspace(input.getResource())) {
......
......@@ -94,7 +94,7 @@ export class DirtyFilesTracker implements IWorkbenchContribution {
private doOpenDirtyResources(resources: URI[]): void {
const activeEditor = this.editorService.getActiveEditor();
const activePosition = activeEditor ? activeEditor.position : Position.ONE;
const activePosition = activeEditor ? activeEditor.group : Position.ONE;
// Open
this.editorService.openEditors(resources.map(resource => {
......
......@@ -148,7 +148,7 @@ function save(resource: URI, isSaveAs: boolean, editorService: IWorkbenchEditorS
const editor = editorService.getActiveEditor();
const activeEditorResource = editor && editor.input && editor.input.getResource();
if (activeEditorResource && activeEditorResource.toString() === resource.toString()) {
editorGroupService.pinEditor(editor.position, editor.input);
editorGroupService.pinEditor(editor.group, editor.input);
}
// Just save
......
......@@ -319,7 +319,7 @@ export const acceptLocalChangesCommand = (accessor: ServicesAccessor, resource:
const editor = editorService.getActiveEditor();
const input = editor.input;
const position = editor.position;
const position = editor.group;
resolverService.createModelReference(resource).then(reference => {
const model = reference.object as ITextFileEditorModel;
......@@ -355,7 +355,7 @@ export const revertLocalChangesCommand = (accessor: ServicesAccessor, resource:
const editor = editorService.getActiveEditor();
const input = editor.input;
const position = editor.position;
const position = editor.group;
resolverService.createModelReference(resource).then(reference => {
const model = reference.object as ITextFileEditorModel;
......
......@@ -10,7 +10,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { ITextModel } from 'vs/editor/common/model';
import { empty as EmptyDisposable, IDisposable, dispose, IReference } from 'vs/base/common/lifecycle';
import { EditorOptions, EditorInput, EditorViewStateMemento } from 'vs/workbench/common/editor';
import { Position } from 'vs/platform/editor/common/editor';
import { GroupIdentifier } from 'vs/platform/editor/common/editor';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { BaseTextEditorModel } from 'vs/workbench/common/editor/textEditorModel';
import { HtmlInput, HtmlInputOptions, areHtmlInputOptionsEqual } from 'vs/workbench/parts/html/common/htmlInput';
......@@ -121,18 +121,9 @@ export class HtmlPreviewPart extends BaseWebviewEditor {
return this._webview;
}
public changePosition(position: Position): void {
// what this actually means is that we got reparented. that
// has caused the webview to stop working and we need to reset it
this._doSetVisible(false);
this._doSetVisible(true);
super.changePosition(position);
}
protected setEditorVisible(visible: boolean, position?: Position): void {
protected setEditorVisible(visible: boolean, group: GroupIdentifier): void {
this._doSetVisible(visible);
super.setEditorVisible(visible, position);
super.setEditorVisible(visible, group);
}
private _doSetVisible(visible: boolean): void {
......@@ -251,11 +242,11 @@ export class HtmlPreviewPart extends BaseWebviewEditor {
}
private saveHTMLPreviewViewState(input: HtmlInput, editorViewState: HtmlPreviewEditorViewState): void {
this.editorViewStateMemento.saveState(input, this.position, editorViewState);
this.editorViewStateMemento.saveState(input, this.group, editorViewState);
}
private loadHTMLPreviewViewState(input: HtmlInput): HtmlPreviewEditorViewState {
return this.editorViewStateMemento.loadState(input, this.position);
return this.editorViewStateMemento.loadState(input, this.group);
}
protected saveMemento(): void {
......
......@@ -14,10 +14,10 @@ import * as arrays from 'vs/base/common/arrays';
import { ArrayNavigator } from 'vs/base/common/iterator';
import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { EditorOptions, EditorInput } from 'vs/workbench/common/editor';
import { EditorOptions, EditorInput, GroupIdentifier } from 'vs/workbench/common/editor';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { ResourceEditorModel } from 'vs/workbench/common/editor/resourceEditorModel';
import { IEditorControl, Position } from 'vs/platform/editor/common/editor';
import { IEditorControl } from 'vs/platform/editor/common/editor';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { BaseTextEditor } from 'vs/workbench/browser/parts/editor/textEditor';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
......@@ -193,14 +193,9 @@ export class PreferencesEditor extends BaseEditor {
return false;
}
protected setEditorVisible(visible: boolean, position: Position): void {
this.sideBySidePreferencesWidget.setEditorVisible(visible, position);
super.setEditorVisible(visible, position);
}
public changePosition(position: Position): void {
this.sideBySidePreferencesWidget.changePosition(position);
super.changePosition(position);
protected setEditorVisible(visible: boolean, group: GroupIdentifier): void {
this.sideBySidePreferencesWidget.setEditorVisible(visible, group);
super.setEditorVisible(visible, group);
}
private updateInput(oldInput: PreferencesEditorInput, newInput: PreferencesEditorInput, options?: EditorOptions): TPromise<void> {
......@@ -858,15 +853,9 @@ class SideBySidePreferencesWidget extends Widget {
}
}
public setEditorVisible(visible: boolean, position: Position): void {
if (this.editablePreferencesEditor) {
this.editablePreferencesEditor.setVisible(visible, position);
}
}
public changePosition(position: Position): void {
public setEditorVisible(visible: boolean, group: GroupIdentifier): void {
if (this.editablePreferencesEditor) {
this.editablePreferencesEditor.changePosition(position);
this.editablePreferencesEditor.setVisible(visible, group);
}
}
......
......@@ -12,15 +12,14 @@ 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 { 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 { IEditorInput, ITextEditorOptions, GroupIdentifier } from 'vs/platform/editor/common/editor';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { getCodeEditor } from 'vs/editor/browser/services/codeEditorService';
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';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
export const GOTO_LINE_PREFIX = ':';
......@@ -31,14 +30,14 @@ export class GotoLineAction extends QuickOpenAction {
constructor(actionId: string, actionLabel: string,
@IQuickOpenService private readonly _quickOpenService: IQuickOpenService,
@IWorkbenchEditorService private readonly editorService: IWorkbenchEditorService
@INextEditorService private readonly editorService: INextEditorService
) {
super(actionId, actionLabel, GOTO_LINE_PREFIX, _quickOpenService);
}
public run(): TPromise<void> {
const editor = getCodeEditor(this.editorService.getActiveEditor());
const editor = this.editorService.activeTextEditorControl as ICodeEditor;
let restoreOptions: IEditorOptions = null;
if (editor) {
......@@ -179,7 +178,7 @@ class GotoLineEntry extends EditorQuickOpenEntry {
// Decorate if possible
if (types.isFunction(codeEditor.changeDecorations)) {
this.handler.decorateOutline(range, codeEditor, 0 /* TODO@grid activeEditor.position */);
this.handler.decorateOutline(range, codeEditor, this.editorService.activeControl.group);
}
}
......@@ -197,9 +196,9 @@ class GotoLineEntry extends EditorQuickOpenEntry {
}
interface IEditorLineDecoration {
group: GroupIdentifier;
rangeHighlightId: string;
lineDecorationId: string;
position: Position;
}
export class GotoLineHandler extends QuickOpenHandler {
......@@ -235,7 +234,7 @@ export class GotoLineHandler extends QuickOpenHandler {
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 {
public decorateOutline(range: IRange, editor: IEditor, group: GroupIdentifier): void {
editor.changeDecorations(changeAccessor => {
const deleteDecorations: string[] = [];
......@@ -273,9 +272,9 @@ export class GotoLineHandler extends QuickOpenHandler {
const lineDecorationId = decorations[1];
this.rangeHighlightDecorationId = {
group,
rangeHighlightId: rangeHighlightId,
lineDecorationId: lineDecorationId,
position: position
};
});
}
......@@ -283,7 +282,7 @@ export class GotoLineHandler extends QuickOpenHandler {
public clearDecorations(): void {
if (this.rangeHighlightDecorationId) {
this.editorService.visibleControls.forEach(editor => {
if (editor.position === this.rangeHighlightDecorationId.position) {
if (editor.group === this.rangeHighlightDecorationId.group) {
const editorControl = <IEditor>editor.getControl();
editorControl.changeDecorations(changeAccessor => {
changeAccessor.deltaDecorations([
......
......@@ -8,7 +8,6 @@
import 'vs/css!./media/gotoSymbolHandler';
import { TPromise } from 'vs/base/common/winjs.base';
import * as nls from 'vs/nls';
import * as errors from 'vs/base/common/errors';
import * as types from 'vs/base/common/types';
import * as strings from 'vs/base/common/strings';
import { IEntryRunContext, Mode, IAutoFocus } from 'vs/base/parts/quickopen/common/quickOpen';
......@@ -17,15 +16,15 @@ import { QuickOpenHandler, EditorQuickOpenEntryGroup, QuickOpenAction } from 'vs
import * as filters from 'vs/base/common/filters';
import { IEditor, IDiffEditorModel, IEditorViewState, ScrollType } from 'vs/editor/common/editorCommon';
import { IModelDecorationsChangeAccessor, OverviewRulerLane, IModelDeltaDecoration, ITextModel } from 'vs/editor/common/model';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { Position, IEditorInput, ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { IEditorInput, ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { getDocumentSymbols } from 'vs/editor/contrib/quickOpen/quickOpen';
import { DocumentSymbolProviderRegistry, SymbolInformation, symbolKindToCssClass } from 'vs/editor/common/modes';
import { getCodeEditor } from 'vs/editor/browser/services/codeEditorService';
import { IRange } from 'vs/editor/common/core/range';
import { themeColorFromId } from 'vs/platform/theme/common/themeService';
import { overviewRulerRangeHighlight } from 'vs/editor/common/view/editorColorRegistry';
import { GroupIdentifier } from 'vs/workbench/common/editor';
import { INextEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/nextEditorService';
export const GOTO_SYMBOL_PREFIX = '@';
export const SCOPE_PREFIX = ':';
......@@ -239,7 +238,7 @@ class OutlineModel extends QuickOpenModel {
}
class SymbolEntry extends EditorQuickOpenEntryGroup {
private editorService: IWorkbenchEditorService;
private editorService: INextEditorService;
private index: number;
private name: string;
private type: string;
......@@ -248,7 +247,7 @@ class SymbolEntry extends EditorQuickOpenEntryGroup {
private range: IRange;
private handler: GotoSymbolHandler;
constructor(index: number, name: string, type: string, description: string, icon: string, range: IRange, highlights: IHighlight[], editorService: IWorkbenchEditorService, handler: GotoSymbolHandler) {
constructor(index: number, name: string, type: string, description: string, icon: string, range: IRange, highlights: IHighlight[], editorService: INextEditorService, handler: GotoSymbolHandler) {
super();
this.index = index;
......@@ -291,7 +290,7 @@ class SymbolEntry extends EditorQuickOpenEntryGroup {
}
public getInput(): IEditorInput {
return this.editorService.getActiveEditorInput();
return this.editorService.activeEditor;
}
public getOptions(pinned?: boolean): ITextEditorOptions {
......@@ -314,17 +313,16 @@ class SymbolEntry extends EditorQuickOpenEntryGroup {
// 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
else {
const range = this.toSelection();
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor) {
const editor = <IEditor>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);
}
}
......@@ -335,14 +333,13 @@ class SymbolEntry extends EditorQuickOpenEntryGroup {
// Select Outline Position
const range = this.toSelection();
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor) {
const editorControl = <IEditor>activeEditor.getControl();
const editorControl = this.editorService.activeTextEditorControl;
if (editorControl) {
editorControl.revealRangeInCenter(range, ScrollType.Smooth);
// Decorate if possible
if (types.isFunction(editorControl.changeDecorations)) {
this.handler.decorateOutline(this.range, range, editorControl, activeEditor.position);
this.handler.decorateOutline(this.range, range, editorControl, this.editorService.activeControl.group);
}
}
......@@ -364,9 +361,9 @@ interface Outline {
}
interface IEditorLineDecoration {
group: GroupIdentifier;
rangeHighlightId: string;
lineDecorationId: string;
position: Position;
}
export class GotoSymbolHandler extends QuickOpenHandler {
......@@ -379,7 +376,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
private activeOutlineRequest: TPromise<OutlineModel>;
constructor(
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
@INextEditorService private editorService: INextEditorService
) {
super();
......@@ -391,8 +388,8 @@ export class GotoSymbolHandler extends QuickOpenHandler {
// Remember view state to be able to restore on cancel
if (!this.lastKnownEditorViewState) {
const editor = this.editorService.getActiveEditor();
this.lastKnownEditorViewState = (<IEditor>editor.getControl()).saveViewState();
const editor = this.editorService.activeTextEditorControl;
this.lastKnownEditorViewState = editor.saveViewState();
}
// Resolve Outline Model
......@@ -420,7 +417,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
public canRun(): boolean | string {
let canRun = false;
const editorControl: IEditor = getCodeEditor(this.editorService.getActiveEditor());
const editorControl = this.editorService.activeTextEditorControl;
if (editorControl) {
let model = editorControl.getModel();
if (model && (<IDiffEditorModel>model).modified && (<IDiffEditorModel>model).original) {
......@@ -479,7 +476,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
}
private doGetActiveOutline(): TPromise<OutlineModel> {
const editorControl: IEditor = getCodeEditor(this.editorService.getActiveEditor());
const editorControl = this.editorService.activeTextEditorControl;
if (editorControl) {
let model = editorControl.getModel();
if (model && (<IDiffEditorModel>model).modified && (<IDiffEditorModel>model).original) {
......@@ -509,7 +506,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
return TPromise.wrap<OutlineModel>(null);
}
public decorateOutline(fullRange: IRange, startRange: IRange, editor: IEditor, position: Position): void {
public decorateOutline(fullRange: IRange, startRange: IRange, editor: IEditor, group: GroupIdentifier): void {
editor.changeDecorations((changeAccessor: IModelDecorationsChangeAccessor) => {
const deleteDecorations: string[] = [];
......@@ -549,17 +546,17 @@ export class GotoSymbolHandler extends QuickOpenHandler {
const lineDecorationId = decorations[1];
this.rangeHighlightDecorationId = {
group,
rangeHighlightId: rangeHighlightId,
lineDecorationId: lineDecorationId,
position: position
};
});
}
public clearDecorations(): void {
if (this.rangeHighlightDecorationId) {
this.editorService.getVisibleEditors().forEach(editor => {
if (editor.position === this.rangeHighlightDecorationId.position) {
this.editorService.visibleControls.forEach(editor => {
if (editor.group === this.rangeHighlightDecorationId.group) {
const editorControl = <IEditor>editor.getControl();
editorControl.changeDecorations((changeAccessor: IModelDecorationsChangeAccessor) => {
changeAccessor.deltaDecorations([
......@@ -584,10 +581,9 @@ export class GotoSymbolHandler extends QuickOpenHandler {
// Restore selection if canceled
if (canceled && this.lastKnownEditorViewState) {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor) {
const editor = <IEditor>activeEditor.getControl();
editor.restoreViewState(this.lastKnownEditorViewState);
const codeEditor = this.editorService.activeTextEditorControl;
if (codeEditor) {
codeEditor.restoreViewState(this.lastKnownEditorViewState);
}
}
......
......@@ -964,7 +964,7 @@ export class RepositoryPanel extends ViewletPanel {
return;
}
this.editorGroupService.pinEditor(activeEditor.position, activeEditorInput);
this.editorGroupService.pinEditor(activeEditor.group, activeEditorInput);
activeEditor.focus();
}
......
......@@ -76,12 +76,12 @@ export class ReleaseNotesManager {
if (this._currentReleaseNotes) {
this._currentReleaseNotes.setName(title);
this._currentReleaseNotes.html = html;
this._webviewEditorService.revealWebview(this._currentReleaseNotes, activeEditor ? activeEditor.position : undefined, false);
this._webviewEditorService.revealWebview(this._currentReleaseNotes, activeEditor ? activeEditor.group : undefined, false); // TODO@grid [EXTENSIONS] adopt group identifier
} else {
this._currentReleaseNotes = this._webviewEditorService.createWebview(
'releaseNotes',
title,
{ viewColumn: activeEditor ? activeEditor.position : Position.ONE, preserveFocus: false },
{ viewColumn: activeEditor ? activeEditor.group : Position.ONE, preserveFocus: false }, // TODO@grid [EXTENSIONS] adopt group identifier
{ tryRestoreScrollPosition: true, enableFindWidget: true },
undefined, {
onDidClickLink: uri => this.onDidClickLink(uri),
......
......@@ -9,11 +9,10 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import URI from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { Position } from 'vs/platform/editor/common/editor';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { EditorOptions } from 'vs/workbench/common/editor';
import { EditorOptions, GroupIdentifier } from 'vs/workbench/common/editor';
import { WebviewEditorInput } from 'vs/workbench/parts/webview/electron-browser/webviewEditorInput';
import { IPartService, Parts } from 'vs/workbench/services/part/common/partService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
......@@ -99,7 +98,7 @@ export class WebviewEditor extends BaseWebviewEditor {
return this._onDidFocusWebview.event;
}
protected setEditorVisible(visible: boolean, position?: Position): void {
protected setEditorVisible(visible: boolean, group: GroupIdentifier): void {
if (this.input && this.input instanceof WebviewEditorInput) {
if (visible) {
this.input.claimWebview(this);
......@@ -119,7 +118,7 @@ export class WebviewEditor extends BaseWebviewEditor {
}
}
super.setEditorVisible(visible, position);
super.setEditorVisible(visible, group);
}
public clearInput() {
......@@ -146,7 +145,7 @@ export class WebviewEditor extends BaseWebviewEditor {
await super.setInput(input, options);
await input.resolve();
await input.updatePosition(this.position);
await input.updateGroup(this.group);
this.updateWebview(input);
}
......
......@@ -6,7 +6,7 @@
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import URI from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { IEditorInput, IEditorModel, Position } from 'vs/platform/editor/common/editor';
import { IEditorInput, IEditorModel, GroupIdentifier } from 'vs/platform/editor/common/editor';
import { EditorInput, EditorModel } from 'vs/workbench/common/editor';
import { IPartService, Parts } from 'vs/workbench/services/part/common/partService';
import { WebviewEvents, WebviewInputOptions, WebviewReviver } from './webviewEditorService';
......@@ -27,7 +27,7 @@ export class WebviewEditorInput extends EditorInput {
private _webview: WebviewElement | undefined;
private _webviewOwner: any;
private _webviewDisposables: IDisposable[] = [];
private _position?: Position;
private _group?: GroupIdentifier;
private _scrollYPercentage: number = 0;
private _state: any;
private _webviewState: string | undefined;
......@@ -99,8 +99,8 @@ export class WebviewEditorInput extends EditorInput {
return other && other === this;
}
public get position(): Position | undefined {
return this._position;
public get group(): GroupIdentifier | undefined {
return this._group;
}
public get html(): string {
......@@ -230,7 +230,7 @@ export class WebviewEditorInput extends EditorInput {
this._currentWebviewHtml = '';
}
public updatePosition(position: Position): void {
this._position = position;
public updateGroup(group: GroupIdentifier): void {
this._group = group;
}
}
......@@ -102,10 +102,10 @@ export class WebviewEditorService implements IWebviewEditorService {
column: Position | null,
preserveFocus: boolean
): void {
if (!column || webview.position === column) {
this._editorService.openEditor(webview, { preserveFocus }, column || webview.position);
if (!column || webview.group === column) { // TODO@grid [EXTENSIONS] adopt group identifier
this._editorService.openEditor(webview, { preserveFocus }, column || webview.group);
} else {
this._editorGroupService.moveEditor(webview, webview.position, column, { preserveFocus });
this._editorGroupService.moveEditor(webview, webview.group, column, { preserveFocus });
}
}
......
......@@ -474,7 +474,7 @@ export class WalkThroughPart extends BaseEditor {
private saveTextEditorViewState(input: WalkThroughInput): void {
const scrollPosition = this.scrollbar.getScrollPosition();
this.editorViewStateMemento.saveState(input, this.position, {
this.editorViewStateMemento.saveState(input, this.group, {
viewState: {
scrollTop: scrollPosition.scrollTop,
scrollLeft: scrollPosition.scrollLeft
......@@ -483,7 +483,7 @@ export class WalkThroughPart extends BaseEditor {
}
private loadTextEditorViewState(input: WalkThroughInput) {
const state = this.editorViewStateMemento.loadState(input, this.position);
const state = this.editorViewStateMemento.loadState(input, this.group);
if (state) {
this.scrollbar.setScrollPosition(state.viewState);
}
......
......@@ -180,7 +180,7 @@ export class HistoryService implements IHistoryService {
}
// Remember as last active editor (can be undefined if none opened)
this.lastActiveEditor = activeEditor ? { editor: activeEditor.input, position: activeEditor.position } : void 0;
this.lastActiveEditor = activeEditor ? { editor: activeEditor.input, position: activeEditor.group } : void 0;
// Dispose old listeners
dispose(this.activeEditorListeners);
......@@ -207,7 +207,7 @@ export class HistoryService implements IHistoryService {
return false;
}
if (identifier.position !== editor.position) {
if (identifier.position !== editor.group) {
return false;
}
......
......@@ -207,7 +207,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
switchSettings(target: ConfigurationTarget, resource: URI): TPromise<void> {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && activeEditor.input instanceof PreferencesEditorInput) {
return this.doSwitchSettings(target, resource, activeEditor.input, null).then(() => null);
return this.doSwitchSettings(target, resource, activeEditor.input, this.nextEditorGroupService.getGroup(activeEditor.group)).then(() => null);
} else {
return this.doOpenSettings(target, resource).then(() => null);
}
......
......@@ -649,7 +649,7 @@ export class TestEditorService implements IWorkbenchEditorService {
return {
input: null,
options: null,
position: null,
group: null,
getId: () => { return null; },
getControl: () => {
return {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册