diff --git a/src/vs/base/common/arrays.ts b/src/vs/base/common/arrays.ts index 36935b19a8e9375dfb2515ccaad3fa61a820bd36..8053f635f15cad2852981e34a406b6e5bdac4354 100644 --- a/src/vs/base/common/arrays.ts +++ b/src/vs/base/common/arrays.ts @@ -24,7 +24,7 @@ export function tail2(arr: T[]): [T[], T] { return [arr.slice(0, arr.length - 1), arr[arr.length - 1]]; } -export function equals(one: T[], other: T[], itemEquals: (a: T, b: T) => boolean = (a, b) => a === b): boolean { +export function equals(one: ReadonlyArray, other: ReadonlyArray, itemEquals: (a: T, b: T) => boolean = (a, b) => a === b): boolean { if (one.length !== other.length) { return false; } diff --git a/src/vs/workbench/parts/webview/electron-browser/webviewEditorService.ts b/src/vs/workbench/parts/webview/electron-browser/webviewEditorService.ts index 15796fb121940df0635021f24c2451616934885a..344a2153402e9876855247b74799ff28c5e6b0a1 100644 --- a/src/vs/workbench/parts/webview/electron-browser/webviewEditorService.ts +++ b/src/vs/workbench/parts/webview/electron-browser/webviewEditorService.ts @@ -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('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; diff --git a/src/vs/workbench/parts/webview/electron-browser/webviewElement.ts b/src/vs/workbench/parts/webview/electron-browser/webviewElement.ts index 163ff3faa75924eb3dca697ce88f9ab617a5912f..8768f97d9df24364243881714c2ec7f9266b8391 100644 --- a/src/vs/workbench/parts/webview/electron-browser/webviewElement.ts +++ b/src/vs/workbench/parts/webview/electron-browser/webviewElement.ts @@ -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,