mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 19:44:25 +01:00
grid - add and use editorGroupToViewColumn
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user