未验证 提交 d2ac0ce6 编写于 作者: B Benjamin Pasero 提交者: GitHub

Open Editors: revisit order of groups to be based on visual order (for #56084) (#56264)

上级 2959c851
......@@ -419,13 +419,16 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
// Mark preferred size as changed
this.resetPreferredSize();
// Events for groupd that got added
// Events for groups that got added
this.getGroups(GroupsOrder.GRID_APPEARANCE).forEach(groupView => {
if (currentGroupViews.indexOf(groupView) === -1) {
this._onDidAddGroup.fire(groupView);
}
});
// Update labels
this.updateGroupLabels();
// Restore focus as needed
if (gridHasFocus) {
this._activeGroup.focus();
......@@ -475,6 +478,9 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
// Event
this._onDidAddGroup.fire(newGroupView);
// Update labels
this.updateGroupLabels();
return newGroupView;
}
......@@ -631,12 +637,8 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
this._activeGroup.focus();
}
// Update labels: since our labels are created using the index of the
// group, removing a group might produce gaps. So we iterate over all
// groups and reassign the label based on the index.
this.getGroups(GroupsOrder.CREATION_TIME).forEach((group, index) => {
group.setLabel(this.getGroupLabel(index + 1));
});
// Update labels
this.updateGroupLabels();
// Update container
this.updateContainer();
......@@ -648,10 +650,6 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
this._onDidRemoveGroup.fire(groupView);
}
private getGroupLabel(index: number): string {
return localize('groupLabel', "Group {0}", index);
}
moveGroup(group: IEditorGroupView | GroupIdentifier, location: IEditorGroupView | GroupIdentifier, direction: GroupDirection): IEditorGroupView {
const sourceView = this.assertGroupView(group);
const targetView = this.assertGroupView(location);
......@@ -887,6 +885,21 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
toggleClass(this.container, 'empty', this.isEmpty());
}
private updateGroupLabels(): void {
// Since our labels are created using the index of the
// group, adding/removing a group might produce gaps.
// So we iterate over all groups and reassign the label
// based on the index.
this.getGroups(GroupsOrder.GRID_APPEARANCE).forEach((group, index) => {
group.setLabel(this.getGroupLabel(index + 1));
});
}
private getGroupLabel(index: number): string {
return localize('groupLabel', "Group {0}", index);
}
private isEmpty(): boolean {
return this.groupViews.size === 1 && this._activeGroup.isEmpty();
}
......
......@@ -117,7 +117,7 @@ export abstract class BaseEditorPicker extends QuickOpenHandler {
// Sorting
if (query.value) {
const groups = this.editorGroupService.getGroups(GroupsOrder.CREATION_TIME);
const groups = this.editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE);
entries.sort((e1, e2) => {
if (e1.group !== e2.group) {
return groups.indexOf(e1.group) - groups.indexOf(e2.group); // older groups first
......@@ -206,7 +206,7 @@ export class AllEditorsPicker extends BaseEditorPicker {
protected getEditorEntries(): EditorPickerEntry[] {
const entries: EditorPickerEntry[] = [];
this.editorGroupService.getGroups(GroupsOrder.CREATION_TIME).forEach(group => {
this.editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE).forEach(group => {
group.editors.forEach(editor => {
entries.push(this.instantiationService.createInstance(EditorPickerEntry, editor, group));
});
......
......@@ -10,7 +10,7 @@ import { IAction, ActionRunner } from 'vs/base/common/actions';
import * as dom from 'vs/base/browser/dom';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IEditorGroupsService, IEditorGroup, GroupChangeKind } from 'vs/workbench/services/group/common/editorGroupsService';
import { IEditorGroupsService, IEditorGroup, GroupChangeKind, GroupsOrder } from 'vs/workbench/services/group/common/editorGroupsService';
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IEditorInput } from 'vs/workbench/common/editor';
......@@ -326,7 +326,7 @@ export class OpenEditorsView extends ViewletPanel {
private get elements(): (IEditorGroup | OpenEditor)[] {
const result: (IEditorGroup | OpenEditor)[] = [];
this.editorGroupService.groups.forEach(g => {
this.editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE).forEach(g => {
if (this.showGroups) {
result.push(g);
}
......@@ -342,7 +342,7 @@ export class OpenEditorsView extends ViewletPanel {
return index;
}
for (let g of this.editorGroupService.groups) {
for (let g of this.editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE)) {
if (g.id === group.id) {
return index + (!!editor ? 1 : 0);
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册