Add side by side editor to tab api proposal

This commit is contained in:
Logan Ramos
2021-09-02 15:17:51 -04:00
parent 8f7396616f
commit fe53ae0c9f
5 changed files with 43 additions and 9 deletions

View File

@@ -642,7 +642,8 @@ export interface MainThreadEditorTabsShape extends IDisposable {
export interface IEditorTabDto {
viewColumn: ViewColumn;
label: string;
resource?: UriComponents;
resource?: UriComponents | { primary?: UriComponents, secondary?: UriComponents };
editorId?: string;
isActive: boolean;
}

View File

@@ -949,7 +949,13 @@ export class ExtHostVariableResolverService extends AbstractVariableResolverServ
}
const tabs = editorTabs.tabs.filter(tab => tab.isActive);
if (tabs.length > 0) {
return tabs[0].resource;
// Resolve a resource from the tab
const asSideBySideResource = tabs[0].resource as { primary?: URI, secondary?: URI } | undefined;
if (asSideBySideResource && (asSideBySideResource.primary || asSideBySideResource.secondary)) {
return asSideBySideResource.primary ?? asSideBySideResource.secondary;
} else {
return tabs[0].resource as URI | undefined;
}
}
}
return undefined;

View File

@@ -5,7 +5,7 @@
import type * as vscode from 'vscode';
import { IEditorTabDto, IExtHostEditorTabsShape } from 'vs/workbench/api/common/extHost.protocol';
import { URI } from 'vs/base/common/uri';
import { URI, UriComponents } from 'vs/base/common/uri';
import { Emitter, Event } from 'vs/base/common/event';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ViewColumn } from 'vs/workbench/api/common/extHostTypes';
@@ -13,8 +13,9 @@ import { ViewColumn } from 'vs/workbench/api/common/extHostTypes';
export interface IEditorTab {
label: string;
viewColumn: ViewColumn;
resource?: vscode.Uri
isActive: boolean
resource?: vscode.Uri | { primary?: vscode.Uri, secondary?: vscode.Uri };
editorId?: string;
isActive: boolean;
}
export interface IExtHostEditorTabs extends IExtHostEditorTabsShape {
@@ -53,10 +54,24 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
if (dto.isActive) {
activeIndex = index;
}
// Resolve resource into the right shape for either normal or side by side
let resource = undefined;
if (dto.resource) {
const resourceAsSidebySide = dto.resource as ({ primary?: UriComponents, secondary?: UriComponents });
if (resourceAsSidebySide.primary || resourceAsSidebySide.secondary) {
resource = {
primary: URI.revive(resourceAsSidebySide.primary),
secondary: URI.revive(resourceAsSidebySide.secondary)
};
} else {
resource = URI.revive(dto.resource as UriComponents | undefined);
}
}
return Object.freeze({
label: dto.label,
viewColumn: dto.viewColumn,
resource: URI.revive(dto.resource),
resource,
editorId: dto.editorId,
isActive: dto.isActive
});
});