mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 11:38:51 +01:00
grid - 💄 for viewcolumn conversion
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user