Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor group model tweaks #143714

Merged
merged 1 commit into from Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/vs/workbench/api/browser/mainThreadEditorTabs.ts
Expand Up @@ -46,7 +46,7 @@ export class MainThreadEditorTabs {
* @param group The group the tab is in
* @returns A tab object
*/
private _buildTabObject(editor: EditorInput, group: IEditorGroup): IEditorTabDto {
private _buildTabObject(group: IEditorGroup, editor: EditorInput, editorIndex: number): IEditorTabDto {
// Even though the id isn't a diff / sideBySide on the main side we need to let the ext host know what type of editor it is
const editorId = editor.editorId;
const tabKind = editor instanceof DiffEditorInput ? TabKind.Diff : editor instanceof SideBySideEditorInput ? TabKind.SidebySide : TabKind.Singular;
Expand All @@ -57,7 +57,7 @@ export class MainThreadEditorTabs {
editorId,
kind: tabKind,
additionalResourcesAndViewIds: [],
isPinned: group.isSticky(editor),
isPinned: group.isSticky(editorIndex),
isActive: group.isActive(editor),
isDirty: editor.isDirty()
};
Expand Down Expand Up @@ -127,15 +127,15 @@ export class MainThreadEditorTabs {
const tabs = this._groupModel.get(groupId)?.tabs;
if (tabs) {
// Splice tab into group at index editorIndex
tabs.splice(editorIndex, 0, this._buildTabObject(editorInput, group));
tabs.splice(editorIndex, 0, this._buildTabObject(group, editorInput, editorIndex));
}
}

/**
* Called when a tab is closed
* @param groupId The id of the group the tab is being removed from
* @param editorIndex The index of the editor within that group
*/
* Called when a tab is closed
* @param groupId The id of the group the tab is being removed from
* @param editorIndex The index of the editor within that group
*/
private _onDidTabClose(groupId: number, editorIndex: number) {
const group = this._editorGroupsService.getGroup(groupId);
const tabs = this._groupModel.get(groupId)?.tabs;
Expand Down Expand Up @@ -231,14 +231,14 @@ export class MainThreadEditorTabs {
activeTab: undefined,
tabs: []
};
for (const editor of group.editors) {
const tab = this._buildTabObject(editor, group);
group.editors.forEach((editor, editorIndex) => {
const tab = this._buildTabObject(group, editor, editorIndex);
// Mark the tab active within the group
if (tab.isActive) {
currentTabGroupModel.activeTab = tab;
}
tabs.push(tab);
}
});
currentTabGroupModel.tabs = tabs;
this._tabGroupModel.push(currentTabGroupModel);
this._groupModel.set(group.id, currentTabGroupModel);
Expand Down
6 changes: 4 additions & 2 deletions src/vs/workbench/common/editor/editorGroupModel.ts
Expand Up @@ -916,11 +916,13 @@ export class EditorGroupModel extends Disposable {
}
}

const strictEquals = editor === candidate;

if (options?.strictEquals) {
return editor === candidate;
return strictEquals;
}

return editor.matches(candidate);
return strictEquals || editor.matches(candidate);
}

get isLocked(): boolean {
Expand Down