提交 06dd68b4 编写于 作者: M Matt Bierner

Fix webviews in same view column not always getting correct state change fired for visibility

Fixes #70859
上级 4f03abce
...@@ -112,7 +112,6 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews ...@@ -112,7 +112,6 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
}; };
this._webviews.set(handle, webview); this._webviews.set(handle, webview);
this._activeWebview = handle;
/* __GDPR__ /* __GDPR__
"webviews:createWebviewPanel" : { "webviews:createWebviewPanel" : {
......
...@@ -72,7 +72,6 @@ export class WebviewEditorInput extends EditorInput { ...@@ -72,7 +72,6 @@ export class WebviewEditorInput extends EditorInput {
constructor( constructor(
public readonly viewType: string, public readonly viewType: string,
id: number,
name: string, name: string,
options: WebviewInputOptions, options: WebviewInputOptions,
state: any, state: any,
...@@ -85,8 +84,7 @@ export class WebviewEditorInput extends EditorInput { ...@@ -85,8 +84,7 @@ export class WebviewEditorInput extends EditorInput {
) { ) {
super(); super();
this._id = id; this._id = WebviewEditorInput.handlePool++;
WebviewEditorInput.handlePool = Math.max(id, WebviewEditorInput.handlePool) + 1;
this._name = name; this._name = name;
this._options = options; this._options = options;
...@@ -99,10 +97,6 @@ export class WebviewEditorInput extends EditorInput { ...@@ -99,10 +97,6 @@ export class WebviewEditorInput extends EditorInput {
return WebviewEditorInput.typeId; return WebviewEditorInput.typeId;
} }
public getId(): number {
return this._id;
}
private readonly _onDidChangeIcon = this._register(new Emitter<void>()); private readonly _onDidChangeIcon = this._register(new Emitter<void>());
public readonly onDidChangeIcon = this._onDidChangeIcon.event; public readonly onDidChangeIcon = this._onDidChangeIcon.event;
...@@ -157,7 +151,7 @@ export class WebviewEditorInput extends EditorInput { ...@@ -157,7 +151,7 @@ export class WebviewEditorInput extends EditorInput {
} }
public matches(other: IEditorInput): boolean { public matches(other: IEditorInput): boolean {
return other === this || (other instanceof WebviewEditorInput && other._id === this._id); return other === this;
} }
public get group(): GroupIdentifier | undefined { public get group(): GroupIdentifier | undefined {
...@@ -312,7 +306,6 @@ export class RevivedWebviewEditorInput extends WebviewEditorInput { ...@@ -312,7 +306,6 @@ export class RevivedWebviewEditorInput extends WebviewEditorInput {
constructor( constructor(
viewType: string, viewType: string,
id: number,
name: string, name: string,
options: WebviewInputOptions, options: WebviewInputOptions,
state: any, state: any,
...@@ -324,7 +317,7 @@ export class RevivedWebviewEditorInput extends WebviewEditorInput { ...@@ -324,7 +317,7 @@ export class RevivedWebviewEditorInput extends WebviewEditorInput {
private readonly reviver: (input: WebviewEditorInput) => Promise<void>, private readonly reviver: (input: WebviewEditorInput) => Promise<void>,
@IWorkbenchLayoutService partService: IWorkbenchLayoutService, @IWorkbenchLayoutService partService: IWorkbenchLayoutService,
) { ) {
super(viewType, id, name, options, state, events, extension, partService); super(viewType, name, options, state, events, extension, partService);
} }
public async resolve(): Promise<IEditorModel> { public async resolve(): Promise<IEditorModel> {
......
...@@ -17,7 +17,6 @@ interface SerializedIconPath { ...@@ -17,7 +17,6 @@ interface SerializedIconPath {
interface SerializedWebview { interface SerializedWebview {
readonly viewType: string; readonly viewType: string;
readonly id: number;
readonly title: string; readonly title: string;
readonly options: WebviewInputOptions; readonly options: WebviewInputOptions;
readonly extensionLocation: string | UriComponents | undefined; readonly extensionLocation: string | UriComponents | undefined;
...@@ -44,7 +43,6 @@ export class WebviewEditorInputFactory implements IEditorInputFactory { ...@@ -44,7 +43,6 @@ export class WebviewEditorInputFactory implements IEditorInputFactory {
const data: SerializedWebview = { const data: SerializedWebview = {
viewType: input.viewType, viewType: input.viewType,
id: input.getId(),
title: input.getName(), title: input.getName(),
options: input.options, options: input.options,
extensionLocation: input.extension ? input.extension.location : undefined, extensionLocation: input.extension ? input.extension.location : undefined,
...@@ -69,7 +67,7 @@ export class WebviewEditorInputFactory implements IEditorInputFactory { ...@@ -69,7 +67,7 @@ export class WebviewEditorInputFactory implements IEditorInputFactory {
const extensionLocation = reviveUri(data.extensionLocation); const extensionLocation = reviveUri(data.extensionLocation);
const extensionId = data.extensionId ? new ExtensionIdentifier(data.extensionId) : undefined; const extensionId = data.extensionId ? new ExtensionIdentifier(data.extensionId) : undefined;
const iconPath = reviveIconPath(data.iconPath); const iconPath = reviveIconPath(data.iconPath);
return this._webviewService.reviveWebview(data.viewType, data.id, data.title, iconPath, data.state, data.options, extensionLocation ? { return this._webviewService.reviveWebview(data.viewType, data.title, iconPath, data.state, data.options, extensionLocation ? {
location: extensionLocation, location: extensionLocation,
id: extensionId id: extensionId
} : undefined, data.group); } : undefined, data.group);
......
...@@ -39,7 +39,6 @@ export interface IWebviewEditorService { ...@@ -39,7 +39,6 @@ export interface IWebviewEditorService {
reviveWebview( reviveWebview(
viewType: string, viewType: string,
id: number,
title: string, title: string,
iconPath: { light: URI, dark: URI } | undefined, iconPath: { light: URI, dark: URI } | undefined,
state: any, state: any,
...@@ -143,7 +142,7 @@ export class WebviewEditorService implements IWebviewEditorService { ...@@ -143,7 +142,7 @@ export class WebviewEditorService implements IWebviewEditorService {
}, },
events: WebviewEvents events: WebviewEvents
): WebviewEditorInput { ): WebviewEditorInput {
const webviewInput = this._instantiationService.createInstance(WebviewEditorInput, viewType, undefined, title, options, {}, events, extension); const webviewInput = this._instantiationService.createInstance(WebviewEditorInput, viewType, title, options, {}, events, extension);
this._editorService.openEditor(webviewInput, { pinned: true, preserveFocus: showOptions.preserveFocus }, showOptions.group); this._editorService.openEditor(webviewInput, { pinned: true, preserveFocus: showOptions.preserveFocus }, showOptions.group);
return webviewInput; return webviewInput;
} }
...@@ -165,7 +164,6 @@ export class WebviewEditorService implements IWebviewEditorService { ...@@ -165,7 +164,6 @@ export class WebviewEditorService implements IWebviewEditorService {
public reviveWebview( public reviveWebview(
viewType: string, viewType: string,
id: number,
title: string, title: string,
iconPath: { light: URI, dark: URI } | undefined, iconPath: { light: URI, dark: URI } | undefined,
state: any, state: any,
...@@ -176,7 +174,7 @@ export class WebviewEditorService implements IWebviewEditorService { ...@@ -176,7 +174,7 @@ export class WebviewEditorService implements IWebviewEditorService {
}, },
group: number | undefined, group: number | undefined,
): WebviewEditorInput { ): WebviewEditorInput {
const webviewInput = this._instantiationService.createInstance(RevivedWebviewEditorInput, viewType, id, title, options, state, {}, extension, async (webview: WebviewEditorInput): Promise<void> => { const webviewInput = this._instantiationService.createInstance(RevivedWebviewEditorInput, viewType, title, options, state, {}, extension, async (webview: WebviewEditorInput): Promise<void> => {
const didRevive = await this.tryRevive(webview); const didRevive = await this.tryRevive(webview);
if (didRevive) { if (didRevive) {
return Promise.resolve(undefined); return Promise.resolve(undefined);
...@@ -220,7 +218,7 @@ export class WebviewEditorService implements IWebviewEditorService { ...@@ -220,7 +218,7 @@ export class WebviewEditorService implements IWebviewEditorService {
// Revived webviews may not have an actively registered reviver but we still want to presist them // Revived webviews may not have an actively registered reviver but we still want to presist them
// since a reviver should exist when it is actually needed. // since a reviver should exist when it is actually needed.
return !(webview instanceof RevivedWebviewEditorInput); return webview instanceof RevivedWebviewEditorInput;
} }
private async tryRevive( private async tryRevive(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册