grid - add action to open editor side by side
This commit is contained in:
parent
59204efd44
commit
9390006a7b
4 changed files with 39 additions and 15 deletions
|
@ -42,7 +42,7 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
|||
import { isMacintosh } from 'vs/base/common/platform';
|
||||
import { GroupOnePicker, GroupTwoPicker, GroupThreePicker, AllEditorsPicker } from 'vs/workbench/browser/parts/editor/editorPicker';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { GridOpenEditorsAction, GridCloseActiveEditorAction, GridRemoveActiveGroupAction, GridOpenOneEditorAction } from 'vs/workbench/browser/parts/editor2/nextEditorActions';
|
||||
import { GridOpenEditorsAction, GridCloseActiveEditorAction, GridRemoveActiveGroupAction, GridOpenOneEditorAction, GridOpenOneEditorSideBySideAction } from 'vs/workbench/browser/parts/editor2/nextEditorActions';
|
||||
|
||||
// Register String Editor
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
|
@ -443,5 +443,6 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(GridOpenEditorsAction,
|
|||
registry.registerWorkbenchAction(new SyncActionDescriptor(GridCloseActiveEditorAction, GridCloseActiveEditorAction.ID, GridCloseActiveEditorAction.LABEL), 'Grid: Close Active Editor', gridCategory);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(GridRemoveActiveGroupAction, GridRemoveActiveGroupAction.ID, GridRemoveActiveGroupAction.LABEL), 'Grid: Remove Active Group', gridCategory);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(GridOpenOneEditorAction, GridOpenOneEditorAction.ID, GridOpenOneEditorAction.LABEL), 'Grid: Open One Editor', gridCategory);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(GridOpenOneEditorSideBySideAction, GridOpenOneEditorSideBySideAction.ID, GridOpenOneEditorSideBySideAction.LABEL), 'Grid: Open One Editor Side by Side', gridCategory);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(SplitEditorGroupHorizontalAction, SplitEditorGroupHorizontalAction.ID, SplitEditorGroupHorizontalAction.LABEL), 'Grid: Split Horizontal', gridCategory);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(SplitEditorGroupVerticalAction, SplitEditorGroupVerticalAction.ID, SplitEditorGroupVerticalAction.LABEL), 'Grid: Split Vertical', gridCategory);
|
|
@ -14,6 +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';
|
||||
|
||||
function getVSCodeBaseFolder(): string {
|
||||
let workingDir = process.cwd();
|
||||
|
@ -93,6 +94,28 @@ export class GridOpenOneEditorAction extends Action {
|
|||
}
|
||||
}
|
||||
|
||||
export class GridOpenOneEditorSideBySideAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.gridOpenOneEditorSideBySide';
|
||||
static readonly LABEL = localize('gridOpenOneEditorSideBySide', "Grid: Open One Editor Side by Side");
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWorkbenchEditorService private legacyEditorService: IWorkbenchEditorService,
|
||||
@INextEditorService private editorService: INextEditorService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
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);
|
||||
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
}
|
||||
|
||||
export class GridCloseActiveEditorAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.gridCloseActiveEditor';
|
||||
|
|
|
@ -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, SIDE_BY_SIDE_VALUE, IEditorInputWithOptions } from 'vs/workbench/services/editor/common/nextEditorService';
|
||||
import { INextEditorService, IResourceEditor, SIDE_BY_SIDE_TYPE, SIDE_BY_SIDE, IEditorInputWithOptions } 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';
|
||||
|
@ -165,8 +165,8 @@ export class NextEditorService extends Disposable implements INextEditorService
|
|||
|
||||
//#region openEditor()
|
||||
|
||||
openEditor(editor: IEditorInput, options?: IEditorOptions, group?: GroupIdentifier | SIDE_BY_SIDE): Thenable<IEditor>;
|
||||
openEditor(editor: IResourceEditor, group?: GroupIdentifier | SIDE_BY_SIDE): Thenable<IEditor>;
|
||||
openEditor(editor: IEditorInput, options?: IEditorOptions, group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable<IEditor>;
|
||||
openEditor(editor: IResourceEditor, group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable<IEditor>;
|
||||
openEditor(editor: IEditorInput | IResourceEditor, optionsOrGroup?: IEditorOptions | GroupIdentifier, group?: GroupIdentifier): Thenable<IEditor> {
|
||||
|
||||
// Typed Editor Support
|
||||
|
@ -193,11 +193,11 @@ export class NextEditorService extends Disposable implements INextEditorService
|
|||
return TPromise.wrap<IEditor>(null);
|
||||
}
|
||||
|
||||
private doOpenEditor(input: IEditorInput, options?: EditorOptions, group?: GroupIdentifier | SIDE_BY_SIDE): Thenable<IEditor> {
|
||||
private doOpenEditor(input: IEditorInput, options?: EditorOptions, group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable<IEditor> {
|
||||
let targetGroup: INextEditorGroup;
|
||||
|
||||
// Group: Side by Side
|
||||
if (group === SIDE_BY_SIDE_VALUE) {
|
||||
if (group === SIDE_BY_SIDE) {
|
||||
targetGroup = this.nextEditorGroupsService.addGroup(this.nextEditorGroupsService.activeGroup, GroupDirection.RIGHT);
|
||||
}
|
||||
|
||||
|
@ -259,9 +259,9 @@ export class NextEditorService extends Disposable implements INextEditorService
|
|||
//#region openEditors()
|
||||
|
||||
// TODO@grid openEditors()
|
||||
openEditors(editors: IEditorInputWithOptions[], group?: GroupIdentifier | SIDE_BY_SIDE): Thenable<IEditor>;
|
||||
openEditors(editors: IResourceEditor[], group?: GroupIdentifier | SIDE_BY_SIDE): Thenable<IEditor>;
|
||||
openEditors(editors: (IEditorInputWithOptions | IResourceEditor)[], group?: GroupIdentifier | SIDE_BY_SIDE): Thenable<IEditor> {
|
||||
openEditors(editors: IEditorInputWithOptions[], group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable<IEditor>;
|
||||
openEditors(editors: IResourceEditor[], group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable<IEditor>;
|
||||
openEditors(editors: (IEditorInputWithOptions | IResourceEditor)[], group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable<IEditor> {
|
||||
const inputs = editors.map(editor => this.createInput(editor));
|
||||
|
||||
return this.openEditor(inputs[0]);
|
||||
|
|
|
@ -15,8 +15,8 @@ export const INextEditorService = createDecorator<INextEditorService>('nextEdito
|
|||
|
||||
export type IResourceEditor = IResourceInput | IUntitledResourceInput | IResourceDiffInput | IResourceSideBySideInput;
|
||||
|
||||
export const SIDE_BY_SIDE_VALUE = -1;
|
||||
export type SIDE_BY_SIDE = typeof SIDE_BY_SIDE_VALUE;
|
||||
export const SIDE_BY_SIDE = -1;
|
||||
export type SIDE_BY_SIDE_TYPE = typeof SIDE_BY_SIDE;
|
||||
|
||||
export interface IEditorInputWithOptions {
|
||||
editor: IEditorInput;
|
||||
|
@ -87,7 +87,7 @@ export interface INextEditorService {
|
|||
* active group. Use `SIDE_BY_SIDE` 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): Thenable<IEditor>;
|
||||
openEditor(editor: IEditorInput, options?: IEditorOptions, group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable<IEditor>;
|
||||
|
||||
/**
|
||||
* Open an editor in an editor group.
|
||||
|
@ -97,7 +97,7 @@ export interface INextEditorService {
|
|||
* active group. Use `SIDE_BY_SIDE` 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): Thenable<IEditor>;
|
||||
openEditor(editor: IResourceEditor, group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable<IEditor>;
|
||||
|
||||
/**
|
||||
* Open editors in an editor group.
|
||||
|
@ -107,8 +107,8 @@ export interface INextEditorService {
|
|||
* active group. Use `SIDE_BY_SIDE` 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): Thenable<IEditor>;
|
||||
openEditors(editors: IResourceEditor[], group?: GroupIdentifier | SIDE_BY_SIDE): Thenable<IEditor>;
|
||||
openEditors(editors: IEditorInputWithOptions[], group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable<IEditor>;
|
||||
openEditors(editors: IResourceEditor[], group?: GroupIdentifier | SIDE_BY_SIDE_TYPE): Thenable<IEditor>;
|
||||
|
||||
/**
|
||||
* Find out if the provided editor (or resource of an editor) is opened in any group.
|
||||
|
|
Loading…
Reference in a new issue