From 2bfb2763fd7f813e52b03b42477bc10ec3a68c8e Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 22 May 2018 08:53:28 +0200 Subject: [PATCH] grid - :lipstick: for viewcolumn conversion --- .../mainThreadDocumentsAndEditors.ts | 4 +- .../api/electron-browser/mainThreadEditors.ts | 41 +++++-------------- .../api/electron-browser/mainThreadWebview.ts | 11 +++-- src/vs/workbench/api/node/apiCommands.ts | 4 +- src/vs/workbench/api/node/extHost.protocol.ts | 18 ++++---- .../workbench/api/node/extHostTextEditors.ts | 4 +- .../api/node/extHostTypeConverters.ts | 6 +-- src/vs/workbench/api/node/extHostWebview.ts | 6 +-- src/vs/workbench/api/shared/editor.ts | 26 +++++++++++- .../electron-browser/html.contribution.ts | 7 ++-- .../api/extHostWebview.test.ts | 6 +-- 11 files changed, 67 insertions(+), 66 deletions(-) diff --git a/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts b/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts index 1fa22534e82..af80931635f 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts @@ -13,7 +13,7 @@ import { ExtHostContext, ExtHostDocumentsAndEditorsShape, IModelAddedData, IText import { MainThreadTextEditor } from './mainThreadEditor'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService'; -import { EditorPosition } from 'vs/workbench/api/shared/editor'; +import { EditorViewColumn } from 'vs/workbench/api/shared/editor'; import { IEditor } from 'vs/workbench/common/editor'; import { extHostCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers'; import { MainThreadDocuments } from 'vs/workbench/api/electron-browser/mainThreadDocuments'; @@ -421,7 +421,7 @@ export class MainThreadDocumentsAndEditors { }; } - private _findEditorPosition(editor: MainThreadTextEditor): EditorPosition { + private _findEditorPosition(editor: MainThreadTextEditor): EditorViewColumn { for (let workbenchEditor of this._editorService.visibleControls) { if (editor.matches(workbenchEditor)) { return this.findEditorPosition(workbenchEditor); diff --git a/src/vs/workbench/api/electron-browser/mainThreadEditors.ts b/src/vs/workbench/api/electron-browser/mainThreadEditors.ts index e234debabec..6be709c2443 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadEditors.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadEditors.ts @@ -18,12 +18,11 @@ import { IRange } from 'vs/editor/common/core/range'; import { ISelection } from 'vs/editor/common/core/selection'; import { IDecorationOptions, IDecorationRenderOptions, ILineChange } from 'vs/editor/common/editorCommon'; import { ISingleEditOperation } from 'vs/editor/common/model'; -import { EditorPosition } from 'vs/workbench/api/shared/editor'; +import { EditorViewColumn, viewColumnToEditorGroup } from 'vs/workbench/api/shared/editor'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { IApplyEditsOptions, ITextEditorConfigurationUpdate, IUndoStopOptions, TextEditorRevealType, WorkspaceEditDto, reviveWorkspaceEditDto } from 'vs/workbench/api/node/extHost.protocol'; -import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService'; +import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService'; -import { GroupIdentifier } from 'vs/workbench/common/editor'; import { ExtHostContext, ExtHostEditorsShape, IExtHostContext, ITextDocumentShowOptions, ITextEditorPositionData, MainThreadTextEditorsShape } from '../node/extHost.protocol'; import { MainThreadDocumentsAndEditors } from './mainThreadDocumentsAndEditors'; import { MainThreadTextEditor } from './mainThreadEditor'; @@ -123,7 +122,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape { options: editorOptions }; - return this._editorService.openEditor(input, findEditorGroup(this._editorGroupService, options.position)).then(editor => { + return this._editorService.openEditor(input, viewColumnToEditorGroup(this._editorGroupService, options.position)).then(editor => { if (!editor) { return undefined; } @@ -131,14 +130,14 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape { }); } - $tryShowEditor(id: string, position?: EditorPosition): TPromise { + $tryShowEditor(id: string, position?: EditorViewColumn): TPromise { let mainThreadEditor = this._documentsAndEditors.getEditor(id); if (mainThreadEditor) { let model = mainThreadEditor.getModel(); return this._editorService.openEditor({ resource: model.uri, options: { preserveFocus: false } - }, findEditorGroup(this._editorGroupService, position)).then(() => { return; }); + }, viewColumnToEditorGroup(this._editorGroupService, position)).then(() => { return; }); } return undefined; } @@ -247,16 +246,16 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape { // --- commands -CommandsRegistry.registerCommand('_workbench.open', function (accessor: ServicesAccessor, args: [URI, IEditorOptions, EditorPosition]) { +CommandsRegistry.registerCommand('_workbench.open', function (accessor: ServicesAccessor, args: [URI, IEditorOptions, EditorViewColumn]) { const editorService = accessor.get(IEditorService); const editorGroupService = accessor.get(IEditorGroupsService); const [resource, options, position] = args; - return editorService.openEditor({ resource, options }, findEditorGroup(editorGroupService, position)).then(() => void 0); + return editorService.openEditor({ resource, options }, viewColumnToEditorGroup(editorGroupService, position)).then(() => void 0); }); -CommandsRegistry.registerCommand('_workbench.diff', function (accessor: ServicesAccessor, args: [URI, URI, string, string, IEditorOptions, EditorPosition]) { +CommandsRegistry.registerCommand('_workbench.diff', function (accessor: ServicesAccessor, args: [URI, URI, string, string, IEditorOptions, EditorViewColumn]) { const editorService = accessor.get(IEditorService); const editorGroupService = accessor.get(IEditorGroupsService); @@ -272,25 +271,5 @@ CommandsRegistry.registerCommand('_workbench.diff', function (accessor: Services label = localize('diffLeftRightLabel', "{0} ⟷ {1}", leftResource.toString(true), rightResource.toString(true)); } - return editorService.openEditor({ leftResource, rightResource, label, description, options }, findEditorGroup(editorGroupService, position)).then(() => void 0); -}); - -export function findEditorGroup(editorGroupService: IEditorGroupsService, position?: EditorPosition): 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 -} \ No newline at end of file + return editorService.openEditor({ leftResource, rightResource, label, description, options }, viewColumnToEditorGroup(editorGroupService, position)).then(() => void 0); +}); \ No newline at end of file diff --git a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts index 9f558d8974b..4b3bd22c9c2 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts @@ -8,7 +8,7 @@ import URI, { UriComponents } from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import { localize } from 'vs/nls'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import { EditorPosition } from 'vs/workbench/api/shared/editor'; +import { EditorViewColumn, viewColumnToEditorGroup } from 'vs/workbench/api/shared/editor'; import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { ExtHostContext, ExtHostWebviewsShape, IExtHostContext, MainContext, MainThreadWebviewsShape, WebviewPanelHandle } from 'vs/workbench/api/node/extHost.protocol'; @@ -19,7 +19,6 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService'; import { extHostNamedCustomer } from './extHostCustomers'; -import { findEditorGroup } from 'vs/workbench/api/electron-browser/mainThreadEditors'; import { GroupIdentifier } from 'vs/workbench/common/editor'; @extHostNamedCustomer(MainContext.MainThreadWebviews) @@ -69,14 +68,14 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv handle: WebviewPanelHandle, viewType: string, title: string, - showOptions: { viewColumn: EditorPosition | null, preserveFocus: boolean }, + showOptions: { viewColumn: EditorViewColumn | null, preserveFocus: boolean }, options: WebviewInputOptions, extensionLocation: UriComponents ): void { const mainThreadShowOptions: ICreateWebViewShowOptions = Object.create(null); if (showOptions) { mainThreadShowOptions.preserveFocus = showOptions.preserveFocus; - mainThreadShowOptions.group = findEditorGroup(this._editorGroupService, showOptions.viewColumn); + mainThreadShowOptions.group = viewColumnToEditorGroup(this._editorGroupService, showOptions.viewColumn); } const webview = this._webviewService.createWebview(MainThreadWebviews.viewType, title, mainThreadShowOptions, options, URI.revive(extensionLocation), this.createWebviewEventDelegate(handle)); @@ -104,13 +103,13 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv webview.html = value; } - $reveal(handle: WebviewPanelHandle, viewColumn: EditorPosition | null, preserveFocus: boolean): void { + $reveal(handle: WebviewPanelHandle, viewColumn: EditorViewColumn | null, preserveFocus: boolean): void { const webview = this.getWebview(handle); if (webview.isDisposed()) { return; } - const targetGroup = this._editorGroupService.getGroup(findEditorGroup(this._editorGroupService, viewColumn)); + const targetGroup = this._editorGroupService.getGroup(viewColumnToEditorGroup(this._editorGroupService, viewColumn)); this._webviewService.revealWebview(webview, targetGroup || this._editorGroupService.activeGroup, preserveFocus); } diff --git a/src/vs/workbench/api/node/apiCommands.ts b/src/vs/workbench/api/node/apiCommands.ts index 14c061349dd..5be2fe4cba7 100644 --- a/src/vs/workbench/api/node/apiCommands.ts +++ b/src/vs/workbench/api/node/apiCommands.ts @@ -9,7 +9,7 @@ import * as vscode from 'vscode'; import * as typeConverters from 'vs/workbench/api/node/extHostTypeConverters'; import { CommandsRegistry, ICommandService, ICommandHandler } from 'vs/platform/commands/common/commands'; import { ITextEditorOptions } from 'vs/platform/editor/common/editor'; -import { EditorPosition } from 'vs/workbench/api/shared/editor'; +import { EditorViewColumn } from 'vs/workbench/api/shared/editor'; // ----------------------------------------------------------------- // The following commands are registered on both sides separately. @@ -71,7 +71,7 @@ export class OpenAPICommand { public static ID = 'vscode.open'; public static execute(executor: ICommandsExecutor, resource: URI, columnOrOptions?: vscode.ViewColumn | vscode.TextDocumentShowOptions): Thenable { let options: ITextEditorOptions; - let position: EditorPosition; + let position: EditorViewColumn; if (columnOrOptions) { if (typeof columnOrOptions === 'number') { diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 809757316cb..771e8bc6b2b 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -13,7 +13,7 @@ import Severity from 'vs/base/common/severity'; import { TPromise } from 'vs/base/common/winjs.base'; import { IMarkerData } from 'vs/platform/markers/common/markers'; -import { EditorPosition } from 'vs/workbench/api/shared/editor'; +import { EditorViewColumn } from 'vs/workbench/api/shared/editor'; import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions'; import { StatusbarAlignment as MainThreadStatusBarAlignment } from 'vs/platform/statusbar/common/statusbar'; import { ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry'; @@ -181,7 +181,7 @@ export interface IApplyEditsOptions extends IUndoStopOptions { } export interface ITextDocumentShowOptions { - position?: EditorPosition; + position?: EditorViewColumn; preserveFocus?: boolean; pinned?: boolean; selection?: IRange; @@ -191,7 +191,7 @@ export interface MainThreadTextEditorsShape extends IDisposable { $tryShowTextDocument(resource: UriComponents, options: ITextDocumentShowOptions): TPromise; $registerTextEditorDecorationType(key: string, options: editorCommon.IDecorationRenderOptions): void; $removeTextEditorDecorationType(key: string): void; - $tryShowEditor(id: string, position: EditorPosition): TPromise; + $tryShowEditor(id: string, position: EditorViewColumn): TPromise; $tryHideEditor(id: string): TPromise; $trySetOptions(id: string, options: ITextEditorConfigurationUpdate): TPromise; $trySetDecorations(id: string, key: string, ranges: editorCommon.IDecorationOptions[]): TPromise; @@ -356,9 +356,9 @@ export interface MainThreadTelemetryShape extends IDisposable { export type WebviewPanelHandle = string; export interface MainThreadWebviewsShape extends IDisposable { - $createWebviewPanel(handle: WebviewPanelHandle, viewType: string, title: string, viewOptions: { viewColumn: EditorPosition, preserveFocus: boolean }, options: vscode.WebviewPanelOptions & vscode.WebviewOptions, extensionLocation: UriComponents): void; + $createWebviewPanel(handle: WebviewPanelHandle, viewType: string, title: string, viewOptions: { viewColumn: EditorViewColumn, preserveFocus: boolean }, options: vscode.WebviewPanelOptions & vscode.WebviewOptions, extensionLocation: UriComponents): void; $disposeWebview(handle: WebviewPanelHandle): void; - $reveal(handle: WebviewPanelHandle, viewColumn: EditorPosition | null, preserveFocus: boolean): void; + $reveal(handle: WebviewPanelHandle, viewColumn: EditorViewColumn | null, preserveFocus: boolean): void; $setTitle(handle: WebviewPanelHandle, value: string): void; $setHtml(handle: WebviewPanelHandle, value: string): void; $postMessage(handle: WebviewPanelHandle, value: any): Thenable; @@ -369,9 +369,9 @@ export interface MainThreadWebviewsShape extends IDisposable { export interface ExtHostWebviewsShape { $onMessage(handle: WebviewPanelHandle, message: any): void; - $onDidChangeWebviewPanelViewState(handle: WebviewPanelHandle, active: boolean, position: EditorPosition): void; + $onDidChangeWebviewPanelViewState(handle: WebviewPanelHandle, active: boolean, position: EditorViewColumn): void; $onDidDisposeWebviewPanel(handle: WebviewPanelHandle): Thenable; - $deserializeWebviewPanel(newWebviewHandle: WebviewPanelHandle, viewType: string, title: string, state: any, position: EditorPosition, options: vscode.WebviewOptions): Thenable; + $deserializeWebviewPanel(newWebviewHandle: WebviewPanelHandle, viewType: string, title: string, state: any, position: EditorViewColumn, options: vscode.WebviewOptions): Thenable; } export interface MainThreadUrlsShape extends IDisposable { @@ -543,10 +543,10 @@ export interface ITextEditorAddData { options: IResolvedTextEditorConfiguration; selections: ISelection[]; visibleRanges: IRange[]; - editorPosition: EditorPosition; + editorPosition: EditorViewColumn; } export interface ITextEditorPositionData { - [id: string]: EditorPosition; + [id: string]: EditorViewColumn; } export interface IEditorPropertiesChangeData { options: IResolvedTextEditorConfiguration | null; diff --git a/src/vs/workbench/api/node/extHostTextEditors.ts b/src/vs/workbench/api/node/extHostTextEditors.ts index b117852e86e..0d997d462bb 100644 --- a/src/vs/workbench/api/node/extHostTextEditors.ts +++ b/src/vs/workbench/api/node/extHostTextEditors.ts @@ -11,7 +11,7 @@ import { TextEditorSelectionChangeKind } from './extHostTypes'; import * as TypeConverters from './extHostTypeConverters'; import { TextEditorDecorationType, ExtHostTextEditor } from './extHostTextEditor'; import { ExtHostDocumentsAndEditors } from './extHostDocumentsAndEditors'; -import { EditorPosition } from 'vs/workbench/api/shared/editor'; +import { EditorViewColumn } from 'vs/workbench/api/shared/editor'; import { MainContext, MainThreadTextEditorsShape, ExtHostEditorsShape, ITextDocumentShowOptions, ITextEditorPositionData, IMainContext, WorkspaceEditDto, IEditorPropertiesChangeData } from './extHost.protocol'; import * as vscode from 'vscode'; @@ -73,7 +73,7 @@ export class ExtHostEditors implements ExtHostEditorsShape { }; } else { options = { - position: 0 as EditorPosition, + position: 0 as EditorViewColumn, preserveFocus: false }; } diff --git a/src/vs/workbench/api/node/extHostTypeConverters.ts b/src/vs/workbench/api/node/extHostTypeConverters.ts index 43cd0b87c99..f5520afd1e9 100644 --- a/src/vs/workbench/api/node/extHostTypeConverters.ts +++ b/src/vs/workbench/api/node/extHostTypeConverters.ts @@ -7,7 +7,7 @@ import * as modes from 'vs/editor/common/modes'; import * as types from './extHostTypes'; import { ITextEditorOptions } from 'vs/platform/editor/common/editor'; -import { EditorPosition } from 'vs/workbench/api/shared/editor'; +import { EditorViewColumn } from 'vs/workbench/api/shared/editor'; import { IDecorationOptions } from 'vs/editor/common/editorCommon'; import { EndOfLineSequence } from 'vs/editor/common/model'; import * as vscode from 'vscode'; @@ -157,7 +157,7 @@ export namespace DiagnosticSeverity { } export namespace ViewColumn { - export function from(column?: vscode.ViewColumn): EditorPosition { + export function from(column?: vscode.ViewColumn): EditorViewColumn { let editorColumn = 0; if (typeof column !== 'number') { // stick with ONE @@ -171,7 +171,7 @@ export namespace ViewColumn { return editorColumn; } - export function to(position?: EditorPosition): vscode.ViewColumn { + export function to(position?: EditorViewColumn): vscode.ViewColumn { if (typeof position !== 'number') { return undefined; } diff --git a/src/vs/workbench/api/node/extHostWebview.ts b/src/vs/workbench/api/node/extHostWebview.ts index 3af0dfb1add..ecaf9a5c215 100644 --- a/src/vs/workbench/api/node/extHostWebview.ts +++ b/src/vs/workbench/api/node/extHostWebview.ts @@ -7,7 +7,7 @@ import { MainContext, MainThreadWebviewsShape, IMainContext, ExtHostWebviewsShap import * as vscode from 'vscode'; import { Event, Emitter } from 'vs/base/common/event'; import * as typeConverters from 'vs/workbench/api/node/extHostTypeConverters'; -import { EditorPosition } from 'vs/workbench/api/shared/editor'; +import { EditorViewColumn } from 'vs/workbench/api/shared/editor'; import { TPromise } from 'vs/base/common/winjs.base'; import { Disposable } from './extHostTypes'; import URI from 'vs/base/common/uri'; @@ -248,7 +248,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape { } } - $onDidChangeWebviewPanelViewState(handle: WebviewPanelHandle, visible: boolean, position: EditorPosition): void { + $onDidChangeWebviewPanelViewState(handle: WebviewPanelHandle, visible: boolean, position: EditorViewColumn): void { const panel = this.getWebviewPanel(handle); if (panel) { const viewColumn = typeConverters.ViewColumn.to(position); @@ -274,7 +274,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape { viewType: string, title: string, state: any, - position: EditorPosition, + position: EditorViewColumn, options: vscode.WebviewOptions & vscode.WebviewPanelOptions ): Thenable { const serializer = this._serializers.get(viewType); diff --git a/src/vs/workbench/api/shared/editor.ts b/src/vs/workbench/api/shared/editor.ts index 77fa626555c..8fc6711edb2 100644 --- a/src/vs/workbench/api/shared/editor.ts +++ b/src/vs/workbench/api/shared/editor.ts @@ -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; \ No newline at end of file +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 +} \ No newline at end of file diff --git a/src/vs/workbench/parts/html/electron-browser/html.contribution.ts b/src/vs/workbench/parts/html/electron-browser/html.contribution.ts index 77cbe9bebc5..dc37a2d223d 100644 --- a/src/vs/workbench/parts/html/electron-browser/html.contribution.ts +++ b/src/vs/workbench/parts/html/electron-browser/html.contribution.ts @@ -9,7 +9,7 @@ import { localize } from 'vs/nls'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; -import { EditorPosition } from 'vs/workbench/api/shared/editor'; +import { EditorViewColumn, viewColumnToEditorGroup } from 'vs/workbench/api/shared/editor'; import { HtmlInput, HtmlInputOptions } from '../common/htmlInput'; import { HtmlPreviewPart } from './htmlPreviewPart'; import { Registry } from 'vs/platform/registry/common/platform'; @@ -17,7 +17,6 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService'; import { IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions'; import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/editor'; -import { findEditorGroup } from 'vs/workbench/api/electron-browser/mainThreadEditors'; function getActivePreviewsForResource(accessor: ServicesAccessor, resource: URI | string) { const uri = resource instanceof URI ? resource : URI.parse(resource); @@ -40,7 +39,7 @@ function getActivePreviewsForResource(accessor: ServicesAccessor, resource: URI CommandsRegistry.registerCommand('_workbench.previewHtml', function ( accessor: ServicesAccessor, resource: URI | string, - position?: EditorPosition, + position?: EditorViewColumn, label?: string ) { const uri = resource instanceof URI ? resource : URI.parse(resource); @@ -81,7 +80,7 @@ CommandsRegistry.registerCommand('_workbench.previewHtml', function ( } return accessor.get(IEditorService) - .openEditor(input, { pinned: true }, findEditorGroup(editorGroupService, position)) + .openEditor(input, { pinned: true }, viewColumnToEditorGroup(editorGroupService, position)) .then(editor => true); }); diff --git a/src/vs/workbench/test/electron-browser/api/extHostWebview.test.ts b/src/vs/workbench/test/electron-browser/api/extHostWebview.test.ts index 19814377273..421b74b97c9 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostWebview.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostWebview.test.ts @@ -11,7 +11,7 @@ import { ExtHostWebviews } from 'vs/workbench/api/node/extHostWebview'; import { mock } from 'vs/workbench/test/electron-browser/api/mock'; import * as vscode from 'vscode'; import { SingleProxyRPCProtocol } from './testRPCProtocol'; -import { EditorPosition } from 'vs/workbench/api/shared/editor'; +import { EditorViewColumn } from 'vs/workbench/api/shared/editor'; suite('ExtHostWebview', function () { @@ -34,7 +34,7 @@ suite('ExtHostWebview', function () { const serializerARegistration = extHostWebviews.registerWebviewPanelSerializer(viewType, serializerA); - await extHostWebviews.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorPosition, {}); + await extHostWebviews.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorViewColumn, {}); assert.strictEqual(lastInvokedDeserializer, serializerA); assert.throws( @@ -45,7 +45,7 @@ suite('ExtHostWebview', function () { extHostWebviews.registerWebviewPanelSerializer(viewType, serializerB); - await extHostWebviews.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorPosition, {}); + await extHostWebviews.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorViewColumn, {}); assert.strictEqual(lastInvokedDeserializer, serializerB); }); });