Skip to content

Commit

Permalink
Update proposed.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
lramos15 committed Sep 21, 2021
1 parent 4cc83ad commit 6c5b3df
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2260,7 +2260,7 @@ declare module 'vscode' {
* {@link Tab.resource resource} and {@link Tab.viewId viewId} will
* always be at index 0.
*/
additionalResourcesAndViewIds?: { resource: Uri, viewId: string }[];
additionalResourcesAndViewIds: { resource?: Uri, viewId?: string }[];

/**
* Whether or not the tab is currently active
Expand Down
35 changes: 20 additions & 15 deletions src/vs/workbench/api/browser/mainThreadEditorTabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { URI } from 'vs/base/common/uri';
import { ExtHostContext, IExtHostEditorTabsShape, IExtHostContext, MainContext, IEditorTabDto } from 'vs/workbench/api/common/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { EditorResourceAccessor, SideBySideEditor } from 'vs/workbench/common/editor';
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
import { SideBySideEditorInput } from 'vs/workbench/common/editor/sideBySideEditorInput';
import { editorGroupToColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
import { GroupChangeKind, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { GroupChangeKind, IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorsChangeEvent, IEditorService } from 'vs/workbench/services/editor/common/editorService';


Expand Down Expand Up @@ -39,6 +40,22 @@ export class MainThreadEditorTabs {
this._dispoables.dispose();
}

private _buildTabObject(editor: EditorInput, group: IEditorGroup): IEditorTabDto {
const tab: IEditorTabDto = {
viewColumn: editorGroupToColumn(this._editorGroupsService, group),
label: editor.getName(),
resource: editor instanceof SideBySideEditorInput ? EditorResourceAccessor.getCanonicalUri(editor, { supportSideBySide: SideBySideEditor.PRIMARY }) : EditorResourceAccessor.getCanonicalUri(editor),
editorId: editor instanceof SideBySideEditorInput ? editor.primary.editorId ?? editor.editorId : editor.editorId,
additionalResourcesAndViewIds: [],
isActive: (this._editorGroupsService.activeGroup === group) && group.isActive(editor)
};
tab.additionalResourcesAndViewIds.push({ resource: tab.resource, viewId: tab.editorId });
if (editor instanceof SideBySideEditorInput) {
tab.additionalResourcesAndViewIds.push({ resource: EditorResourceAccessor.getCanonicalUri(editor, { supportSideBySide: SideBySideEditor.SECONDARY }), viewId: editor.primary.editorId ?? editor.editorId });
}
return tab;
}

private _createTabsModel(): void {
this._tabModel.clear();
let tabs: IEditorTabDto[] = [];
Expand All @@ -47,13 +64,7 @@ export class MainThreadEditorTabs {
if (editor.isDisposed()) {
continue;
}
const tab = {
viewColumn: editorGroupToColumn(this._editorGroupsService, group),
label: editor.getName(),
resource: editor instanceof SideBySideEditorInput ? EditorResourceAccessor.getCanonicalUri(editor, { supportSideBySide: SideBySideEditor.PRIMARY }) : EditorResourceAccessor.getCanonicalUri(editor),
editorId: editor.editorId,
isActive: (this._editorGroupsService.activeGroup === group) && group.isActive(editor)
};
const tab = this._buildTabObject(editor, group);
if (tab.isActive) {
this._currentlyActiveTab = { groupId: group.id, tab };
}
Expand All @@ -72,13 +83,7 @@ export class MainThreadEditorTabs {
this._tabModel.set(event.groupId, []);
}
const editor = event.editor;
const tab = {
viewColumn: editorGroupToColumn(this._editorGroupsService, event.groupId),
label: editor.getName(),
resource: editor instanceof SideBySideEditorInput ? EditorResourceAccessor.getCanonicalUri(editor, { supportSideBySide: SideBySideEditor.PRIMARY }) : EditorResourceAccessor.getCanonicalUri(editor),
editorId: editor.editorId,
isActive: (this._editorGroupsService.activeGroup.id === event.groupId) && this._editorGroupsService.activeGroup.isActive(editor)
};
const tab = this._buildTabObject(editor, this._editorGroupsService.getGroup(event.groupId) ?? this._editorGroupsService.activeGroup);
this._tabModel.get(event.groupId)?.splice(event.editorIndex, 0, tab);
// Update the currently active tab which may or may not be the opened one
if (tab.isActive) {
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ export interface IEditorTabDto {
resource?: UriComponents;
editorId?: string;
isActive: boolean;
additionalResourcesAndViewIds: { resource?: UriComponents, viewId?: string }[]
}

export interface IExtHostEditorTabsShape {
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/api/common/extHostEditorTabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface IEditorTab {
resource?: vscode.Uri;
viewId?: string;
isActive: boolean;
additionalResourcesAndViewIds: { resource?: vscode.Uri, viewId?: string }[]
}

export interface IExtHostEditorTabs extends IExtHostEditorTabsShape {
Expand Down Expand Up @@ -61,6 +62,7 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
viewColumn: typeConverters.ViewColumn.to(dto.viewColumn),
index,
resource: URI.revive(dto.resource),
additionalResourcesAndViewIds: dto.additionalResourcesAndViewIds.map(({ resource, viewId }) => ({ resource: URI.revive(resource), viewId })),
viewId: dto.editorId,
isActive: dto.isActive
});
Expand Down

0 comments on commit 6c5b3df

Please sign in to comment.