提交 d770ce50 编写于 作者: M Matt Bierner

Make sure we handle webview position updates when an entire editor group moves

上级 be4e48fb
......@@ -4964,8 +4964,10 @@ declare module 'vscode' {
*
* A webview panel may only show in a single column at a time. If it is already showing, this
* method moves it to a new column.
*
* @param viewColumn View column to show the panel in. Shows in the current `viewColumn` if undefined.
*/
reveal(viewColumn: ViewColumn): void;
reveal(viewColumn?: ViewColumn): void;
/**
* Dispose of the webview panel.
......
......@@ -52,6 +52,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
) {
this._proxy = context.getProxy(ExtHostContext.ExtHostWebviews);
editorGroupService.onEditorsChanged(this.onEditorsChanged, this, this._toDispose);
editorGroupService.onEditorGroupMoved(this.onEditorGroupMoved, this, this._toDispose);
this._toDispose.push(_webviewService.registerReviver(MainThreadWebviews.viewType, this));
......@@ -96,7 +97,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
webview.html = value;
}
$reveal(handle: WebviewPanelHandle, column: Position): void {
$reveal(handle: WebviewPanelHandle, column: Position | undefined): void {
const webview = this.getWebview(handle);
this._webviewService.revealWebview(webview, column);
}
......@@ -227,6 +228,20 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
}
}
private onEditorGroupMoved(): void {
for (const workbenchEditor of this._editorService.getVisibleEditors()) {
if (!workbenchEditor.input) {
return;
}
this._webviews.forEach((input, handle) => {
if (workbenchEditor.input.matches(input) && input.position !== workbenchEditor.position) {
input.updatePosition(workbenchEditor.position);
this._proxy.$onDidChangeWebviewPanelViewState(handle, handle === this._activeWebview, workbenchEditor.position);
}
});
}
}
private onDidClickLink(handle: WebviewPanelHandle, link: URI): void {
if (!link) {
return;
......
......@@ -355,7 +355,7 @@ export type WebviewPanelHandle = string;
export interface MainThreadWebviewsShape extends IDisposable {
$createWebviewPanel(handle: WebviewPanelHandle, viewType: string, title: string, column: EditorPosition, options: vscode.WebviewPanelOptions & vscode.WebviewOptions, extensionFolderPath: string): void;
$disposeWebview(handle: WebviewPanelHandle): void;
$reveal(handle: WebviewPanelHandle, column: EditorPosition): void;
$reveal(handle: WebviewPanelHandle, column: EditorPosition | undefined): void;
$setTitle(handle: WebviewPanelHandle, value: string): void;
$setHtml(handle: WebviewPanelHandle, value: string): void;
$postMessage(handle: WebviewPanelHandle, value: any): Thenable<boolean>;
......
......@@ -58,11 +58,6 @@ export class ExtHostWebview implements vscode.Webview {
return this._proxy.$postMessage(this._handle, message);
}
public reveal(viewColumn: vscode.ViewColumn): void {
this.assertNotDisposed();
this._proxy.$reveal(this._handle, typeConverters.fromViewColumn(viewColumn));
}
private assertNotDisposed() {
if (this._isDisposed) {
throw new Error('Webview is disposed');
......@@ -176,9 +171,9 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel {
return this._proxy.$postMessage(this._handle, message);
}
public reveal(viewColumn: vscode.ViewColumn): void {
public reveal(viewColumn?: vscode.ViewColumn): void {
this.assertNotDisposed();
this._proxy.$reveal(this._handle, typeConverters.fromViewColumn(viewColumn));
this._proxy.$reveal(this._handle, viewColumn ? typeConverters.fromViewColumn(viewColumn) : undefined);
}
private assertNotDisposed() {
......
......@@ -148,7 +148,7 @@ export class WebviewEditor extends BaseWebviewEditor {
await super.setInput(input, options);
await input.resolve();
await input.onBecameActive(this.position);
await input.updatePosition(this.position);
this.updateWebview(input);
}
......
......@@ -224,7 +224,7 @@ export class WebviewEditorInput extends EditorInput {
this._currentWebviewHtml = '';
}
public onBecameActive(position: Position): void {
public updatePosition(position: Position): void {
this._position = position;
}
}
......@@ -100,11 +100,7 @@ export class WebviewEditorService implements IWebviewEditorService {
webview: WebviewEditorInput,
column: Position | undefined
): void {
if (typeof column === 'undefined') {
column = webview.position;
}
if (webview.position === column) {
if (typeof column === 'undefined' || webview.position === column) {
this._editorService.openEditor(webview, { preserveFocus: false }, column);
} else {
this._editorGroupService.moveEditor(webview, webview.position, column, { preserveFocus: false });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册