mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-26 05:07:35 +00:00
Use _private
This commit is contained in:
@@ -16,33 +16,33 @@ import { MarkdownContentProvider } from './previewContentProvider';
|
||||
export class MarkdownPreviewManager implements vscode.WebviewPanelSerializer {
|
||||
private static readonly markdownPreviewActiveContextKey = 'markdownPreviewFocus';
|
||||
|
||||
private readonly topmostLineMonitor = new MarkdownFileTopmostLineMonitor();
|
||||
private readonly previewConfigurations = new MarkdownPreviewConfigurationManager();
|
||||
private readonly previews: MarkdownPreview[] = [];
|
||||
private activePreview: MarkdownPreview | undefined = undefined;
|
||||
private readonly disposables: vscode.Disposable[] = [];
|
||||
private readonly _topmostLineMonitor = new MarkdownFileTopmostLineMonitor();
|
||||
private readonly _previewConfigurations = new MarkdownPreviewConfigurationManager();
|
||||
private readonly _previews: MarkdownPreview[] = [];
|
||||
private _activePreview: MarkdownPreview | undefined = undefined;
|
||||
private readonly _disposables: vscode.Disposable[] = [];
|
||||
|
||||
public constructor(
|
||||
private readonly contentProvider: MarkdownContentProvider,
|
||||
private readonly logger: Logger,
|
||||
private readonly contributions: MarkdownContributions
|
||||
private readonly _contentProvider: MarkdownContentProvider,
|
||||
private readonly _logger: Logger,
|
||||
private readonly _contributions: MarkdownContributions
|
||||
) {
|
||||
this.disposables.push(vscode.window.registerWebviewPanelSerializer(MarkdownPreview.viewType, this));
|
||||
this._disposables.push(vscode.window.registerWebviewPanelSerializer(MarkdownPreview.viewType, this));
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
disposeAll(this.disposables);
|
||||
disposeAll(this.previews);
|
||||
disposeAll(this._disposables);
|
||||
disposeAll(this._previews);
|
||||
}
|
||||
|
||||
public refresh() {
|
||||
for (const preview of this.previews) {
|
||||
for (const preview of this._previews) {
|
||||
preview.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public updateConfiguration() {
|
||||
for (const preview of this.previews) {
|
||||
for (const preview of this._previews) {
|
||||
preview.updateConfiguration();
|
||||
}
|
||||
}
|
||||
@@ -62,16 +62,16 @@ export class MarkdownPreviewManager implements vscode.WebviewPanelSerializer {
|
||||
}
|
||||
|
||||
public get activePreviewResource() {
|
||||
return this.activePreview && this.activePreview.resource;
|
||||
return this._activePreview && this._activePreview.resource;
|
||||
}
|
||||
|
||||
public toggleLock() {
|
||||
const preview = this.activePreview;
|
||||
const preview = this._activePreview;
|
||||
if (preview) {
|
||||
preview.toggleLock();
|
||||
|
||||
// Close any previews that are now redundant, such as having two dynamic previews in the same editor group
|
||||
for (const otherPreview of this.previews) {
|
||||
for (const otherPreview of this._previews) {
|
||||
if (otherPreview !== preview && preview.matches(otherPreview)) {
|
||||
otherPreview.dispose();
|
||||
}
|
||||
@@ -86,10 +86,10 @@ export class MarkdownPreviewManager implements vscode.WebviewPanelSerializer {
|
||||
const preview = await MarkdownPreview.revive(
|
||||
webview,
|
||||
state,
|
||||
this.contentProvider,
|
||||
this.previewConfigurations,
|
||||
this.logger,
|
||||
this.topmostLineMonitor);
|
||||
this._contentProvider,
|
||||
this._previewConfigurations,
|
||||
this._logger,
|
||||
this._topmostLineMonitor);
|
||||
|
||||
this.registerPreview(preview);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ export class MarkdownPreviewManager implements vscode.WebviewPanelSerializer {
|
||||
resource: vscode.Uri,
|
||||
previewSettings: PreviewSettings
|
||||
): MarkdownPreview | undefined {
|
||||
return this.previews.find(preview =>
|
||||
return this._previews.find(preview =>
|
||||
preview.matchesResource(resource, previewSettings.previewColumn, previewSettings.locked));
|
||||
}
|
||||
|
||||
@@ -110,39 +110,39 @@ export class MarkdownPreviewManager implements vscode.WebviewPanelSerializer {
|
||||
resource,
|
||||
previewSettings.previewColumn,
|
||||
previewSettings.locked,
|
||||
this.contentProvider,
|
||||
this.previewConfigurations,
|
||||
this.logger,
|
||||
this.topmostLineMonitor,
|
||||
this.contributions);
|
||||
this._contentProvider,
|
||||
this._previewConfigurations,
|
||||
this._logger,
|
||||
this._topmostLineMonitor,
|
||||
this._contributions);
|
||||
|
||||
this.setPreviewActiveContext(true);
|
||||
this.activePreview = preview;
|
||||
this._activePreview = preview;
|
||||
return this.registerPreview(preview);
|
||||
}
|
||||
|
||||
private registerPreview(
|
||||
preview: MarkdownPreview
|
||||
): MarkdownPreview {
|
||||
this.previews.push(preview);
|
||||
this._previews.push(preview);
|
||||
|
||||
preview.onDispose(() => {
|
||||
const existing = this.previews.indexOf(preview);
|
||||
const existing = this._previews.indexOf(preview);
|
||||
if (existing === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.previews.splice(existing, 1);
|
||||
if (this.activePreview === preview) {
|
||||
this._previews.splice(existing, 1);
|
||||
if (this._activePreview === preview) {
|
||||
this.setPreviewActiveContext(false);
|
||||
this.activePreview = undefined;
|
||||
this._activePreview = undefined;
|
||||
}
|
||||
});
|
||||
|
||||
preview.onDidChangeViewState(({ webviewPanel }) => {
|
||||
disposeAll(this.previews.filter(otherPreview => preview !== otherPreview && preview!.matches(otherPreview)));
|
||||
disposeAll(this._previews.filter(otherPreview => preview !== otherPreview && preview!.matches(otherPreview)));
|
||||
this.setPreviewActiveContext(webviewPanel.visible);
|
||||
this.activePreview = webviewPanel.visible ? preview : undefined;
|
||||
this._activePreview = webviewPanel.visible ? preview : undefined;
|
||||
});
|
||||
|
||||
return preview;
|
||||
|
||||
Reference in New Issue
Block a user