grid - 💄 for viewcolumn conversion

This commit is contained in:
Benjamin Pasero
2018-05-22 08:53:28 +02:00
parent f0abfa346e
commit 2bfb2763fd
11 changed files with 67 additions and 66 deletions

View File

@@ -5,7 +5,31 @@
'use strict';
import { IEditorGroupsService } 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
export type EditorPosition = number;
export type EditorViewColumn = number;
export function viewColumnToEditorGroup(editorGroupService: IEditorGroupsService, position?: EditorViewColumn): GroupIdentifier {
if (typeof position !== 'number') {
return ACTIVE_GROUP; // prefer active group when position is undefined
}
const groups = editorGroupService.groups;
let candidate = groups[position];
if (candidate) {
return candidate.id; // found direct match
}
let firstGroup = groups[0];
if (groups.length === 1 && firstGroup.count === 0) {
return firstGroup.id; // first editor should always open in first group
}
return SIDE_GROUP; // open to the side if group not found
}