提交 23f1fdce 编写于 作者: M Matt Bierner

Fix retainContextWhileHidden

Fixes #52073
上级 c28bbded
......@@ -24,7 +24,7 @@ export function tail2<T>(arr: T[]): [T[], T] {
return [arr.slice(0, arr.length - 1), arr[arr.length - 1]];
}
export function equals<T>(one: T[], other: T[], itemEquals: (a: T, b: T) => boolean = (a, b) => a === b): boolean {
export function equals<T>(one: ReadonlyArray<T>, other: ReadonlyArray<T>, itemEquals: (a: T, b: T) => boolean = (a, b) => a === b): boolean {
if (one.length !== other.length) {
return false;
}
......
......@@ -12,6 +12,7 @@ import { IEditorGroupsService, IEditorGroup } from 'vs/workbench/services/group/
import * as vscode from 'vscode';
import { WebviewEditorInput } from './webviewEditorInput';
import { GroupIdentifier } from 'vs/workbench/common/editor';
import { equals } from 'vs/base/common/arrays';
export const IWebviewEditorService = createDecorator<IWebviewEditorService>('webviewEditorService');
......@@ -76,6 +77,15 @@ export interface WebviewInputOptions extends vscode.WebviewOptions, vscode.Webvi
tryRestoreScrollPosition?: boolean;
}
export function areWebviewInputOptionsEqual(a: WebviewInputOptions, b: WebviewInputOptions): boolean {
return a.enableCommandUris === b.enableCommandUris
&& a.enableFindWidget === b.enableFindWidget
&& a.enableScripts === b.enableScripts
&& a.retainContextWhenHidden === b.retainContextWhenHidden
&& a.tryRestoreScrollPosition === b.tryRestoreScrollPosition
&& (a.localResourceRoots === b.localResourceRoots || (Array.isArray(a.localResourceRoots) && Array.isArray(b.localResourceRoots) && equals(a.localResourceRoots, b.localResourceRoots, (a, b) => a.toString() === b.toString())));
}
export class WebviewEditorService implements IWebviewEditorService {
_serviceBrand: any;
......
......@@ -17,6 +17,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import * as colorRegistry from 'vs/platform/theme/common/colorRegistry';
import { DARK, ITheme, IThemeService, LIGHT } from 'vs/platform/theme/common/themeService';
import { WebviewFindWidget } from './webviewFindWidget';
import { areWebviewInputOptionsEqual } from './webviewEditorService';
export interface WebviewOptions {
readonly allowScripts?: boolean;
......@@ -255,6 +256,10 @@ export class WebviewElement extends Disposable {
}
public set options(value: WebviewOptions) {
if (this._options && areWebviewInputOptionsEqual(value, this._options)) {
return;
}
this._options = value;
this._send('content', {
contents: this._contents,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册