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

Delay updateStyleSheet until we are starting the workbench

上级 16ee9639
......@@ -14,6 +14,7 @@ import { URI } from 'vs/base/common/uri';
import { WebviewContentState } from 'vs/editor/common/modes';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { ILabelService } from 'vs/platform/label/common/label';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { ConfirmResult, IEditorInput, Verbosity } from 'vs/workbench/common/editor';
import { WebviewEditorOverlay } from 'vs/workbench/contrib/webview/browser/webview';
import { IWebviewWorkbenchService, LazilyResolvedWebviewEditorInput } from 'vs/workbench/contrib/webview/browser/webviewWorkbenchService';
......@@ -31,11 +32,12 @@ export class CustomFileEditorInput extends LazilyResolvedWebviewEditorInput {
viewType: string,
id: string,
webview: Lazy<UnownedDisposable<WebviewEditorOverlay>>,
@ILifecycleService lifecycleService: ILifecycleService,
@IWebviewWorkbenchService webviewWorkbenchService: IWebviewWorkbenchService,
@IDialogService private readonly dialogService: IDialogService,
@ILabelService private readonly labelService: ILabelService,
) {
super(id, viewType, '', webview, webviewWorkbenchService);
super(id, viewType, '', webview, webviewWorkbenchService, lifecycleService);
this._editorResource = resource;
}
......
......@@ -9,6 +9,7 @@ import { Lazy } from 'vs/base/common/lazy';
import { UnownedDisposable as Unowned } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { IEditorModel } from 'vs/platform/editor/common/editor';
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { EditorInput, EditorModel, GroupIdentifier, IEditorInput, Verbosity } from 'vs/workbench/common/editor';
import { WebviewEditorOverlay } from 'vs/workbench/contrib/webview/browser/webview';
......@@ -17,6 +18,7 @@ const WebviewPanelResourceScheme = 'webview-panel';
class WebviewIconsManager {
private readonly _icons = new Map<string, { light: URI, dark: URI }>();
@memoize
private get _styleElement(): HTMLStyleElement {
const element = dom.createStyleSheet();
......@@ -26,7 +28,8 @@ class WebviewIconsManager {
public setIcons(
webviewId: string,
iconPath: { light: URI, dark: URI } | undefined
iconPath: { light: URI, dark: URI } | undefined,
lifecycleService: ILifecycleService,
) {
if (iconPath) {
this._icons.set(webviewId, iconPath);
......@@ -34,10 +37,11 @@ class WebviewIconsManager {
this._icons.delete(webviewId);
}
this.updateStyleSheet();
this.updateStyleSheet(lifecycleService);
}
private updateStyleSheet() {
private async updateStyleSheet(lifecycleService: ILifecycleService, ) {
await lifecycleService.when(LifecyclePhase.Starting);
const cssRules: string[] = [];
this._icons.forEach((value, key) => {
const webviewSelector = `.show-file-icons .webview-${key}-name-file-icon::before`;
......@@ -67,7 +71,8 @@ export class WebviewInput extends EditorInput {
public readonly id: string,
public readonly viewType: string,
name: string,
webview: Lazy<Unowned<WebviewEditorOverlay>>
webview: Lazy<Unowned<WebviewEditorOverlay>>,
@ILifecycleService private readonly lifecycleService: ILifecycleService,
) {
super();
......@@ -118,7 +123,7 @@ export class WebviewInput extends EditorInput {
public set iconPath(value: { light: URI, dark: URI } | undefined) {
this._iconPath = value;
WebviewInput.iconsManager.setIcons(this.id, value);
WebviewInput.iconsManager.setIcons(this.id, value, this.lifecycleService);
}
public matches(other: IEditorInput): boolean {
......
......@@ -5,19 +5,20 @@
import { equals } from 'vs/base/common/arrays';
import { memoize } from 'vs/base/common/decorators';
import { Lazy } from 'vs/base/common/lazy';
import { IDisposable, toDisposable, UnownedDisposable } from 'vs/base/common/lifecycle';
import { values } from 'vs/base/common/map';
import { isEqual } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { EditorActivation, IEditorModel } from 'vs/platform/editor/common/editor';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { GroupIdentifier } from 'vs/workbench/common/editor';
import { IWebviewService, WebviewContentOptions, WebviewEditorOverlay, WebviewOptions, WebviewExtensionDescription } from 'vs/workbench/contrib/webview/browser/webview';
import { IWebviewService, WebviewContentOptions, WebviewEditorOverlay, WebviewExtensionDescription, WebviewOptions } from 'vs/workbench/contrib/webview/browser/webview';
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { ACTIVE_GROUP_TYPE, IEditorService, SIDE_GROUP_TYPE } from 'vs/workbench/services/editor/common/editorService';
import { WebviewInput } from './webviewEditorInput';
import { Lazy } from 'vs/base/common/lazy';
export const IWebviewWorkbenchService = createDecorator<IWebviewWorkbenchService>('webviewEditorService');
......@@ -109,8 +110,9 @@ export class LazilyResolvedWebviewEditorInput extends WebviewInput {
name: string,
webview: Lazy<UnownedDisposable<WebviewEditorOverlay>>,
@IWebviewWorkbenchService private readonly _webviewWorkbenchService: IWebviewWorkbenchService,
@ILifecycleService lifeCycleService: ILifecycleService,
) {
super(id, viewType, name, webview);
super(id, viewType, name, webview, lifeCycleService);
}
@memoize
......@@ -145,8 +147,9 @@ export class WebviewEditorService implements IWebviewWorkbenchService {
private readonly _revivalPool = new RevivalPool();
constructor(
@IEditorService private readonly _editorService: IEditorService,
@IEditorGroupsService private readonly _editorGroupService: IEditorGroupsService,
@IEditorService private readonly _editorService: IEditorService,
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@IWebviewService private readonly _webviewService: IWebviewService,
) { }
......@@ -159,7 +162,7 @@ export class WebviewEditorService implements IWebviewWorkbenchService {
extension: WebviewExtensionDescription | undefined,
): WebviewInput {
const webview = new Lazy(() => new UnownedDisposable(this.createWebiew(id, extension, options)));
const webviewInput = new WebviewInput(id, viewType, title, webview);
const webviewInput = this._instantiationService.createInstance(WebviewInput, id, viewType, title, webview);
this._editorService.openEditor(webviewInput, {
pinned: true,
preserveFocus: showOptions.preserveFocus,
......@@ -206,7 +209,7 @@ export class WebviewEditorService implements IWebviewWorkbenchService {
return new UnownedDisposable(webview);
});
const webviewInput = new LazilyResolvedWebviewEditorInput(id, viewType, title, webview, this);
const webviewInput = this._instantiationService.createInstance(LazilyResolvedWebviewEditorInput, id, viewType, title, webview);
webviewInput.iconPath = iconPath;
if (typeof group === 'number') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册