grid - add and use editorGroupToViewColumn

This commit is contained in:
Benjamin Pasero
2018-05-22 11:07:08 +02:00
parent dbcf54ccb4
commit db3acf9e92
4 changed files with 21 additions and 25 deletions

View File

@@ -5,13 +5,14 @@
'use strict';
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
import { IEditorGroupsService, IEditorGroup, GroupsOrder } from 'vs/workbench/services/group/common/editorGroupsService';
import { GroupIdentifier } from 'vs/workbench/common/editor';
import { ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
// TODO@api this was previously a hardcoded list of editor positions (ONE, TWO, THREE)
// that with the introduction of grid editor feature is now unbounded. This should be
// revisited when the grid functionality is exposed to extensions
// revisited when the grid functionality is exposed to extensions,
export type EditorViewColumn = number;
export function viewColumnToEditorGroup(editorGroupService: IEditorGroupsService, position?: EditorViewColumn): GroupIdentifier {
@@ -19,7 +20,7 @@ export function viewColumnToEditorGroup(editorGroupService: IEditorGroupsService
return ACTIVE_GROUP; // prefer active group when position is undefined
}
const groups = editorGroupService.groups;
const groups = editorGroupService.getGroups(GroupsOrder.CREATION_TIME);
let candidate = groups[position];
if (candidate) {
@@ -32,4 +33,10 @@ export function viewColumnToEditorGroup(editorGroupService: IEditorGroupsService
}
return SIDE_GROUP; // open to the side if group not found
}
export function editorGroupToViewColumn(editorGroupService: IEditorGroupsService, editorGroup: IEditorGroup | GroupIdentifier): EditorViewColumn {
const group = typeof editorGroup === 'number' ? editorGroupService.getGroup(editorGroup) : editorGroup;
return editorGroupService.getGroups(GroupsOrder.CREATION_TIME).indexOf(group);
}