Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/diffs/src/components/File.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class File<LAnnotation = undefined> {
protected errorWrapper: HTMLElement | undefined;
protected placeHolder: HTMLElement | undefined;
protected lastRenderedHeaderHTML: string | undefined;
protected cachedHeaderHTML: string | undefined;
protected appliedPreAttributes: PrePropertiesConfig | undefined;
protected lastRowCount: number | undefined;

Expand Down Expand Up @@ -190,6 +191,7 @@ export class File<LAnnotation = undefined> {
public setOptions(options: FileOptions<LAnnotation> | undefined): void {
if (options == null) return;
this.options = options;
this.cachedHeaderHTML = undefined;
this.interactionManager.setOptions(pluckInteractionOptions(options));
}

Expand Down Expand Up @@ -289,6 +291,9 @@ export class File<LAnnotation = undefined> {
this.headerMetadata = undefined;
this.headerCustom = undefined;
this.lastRenderedHeaderHTML = undefined;
if (!recycle) {
this.cachedHeaderHTML = undefined;
}
this.errorWrapper = undefined;
this.themeCSSStyle = undefined;
this.appliedThemeCSS = undefined;
Expand Down Expand Up @@ -457,6 +462,9 @@ export class File<LAnnotation = undefined> {
}

this.renderRange = nextRenderRange;
if (didFileChange) {
this.cachedHeaderHTML = undefined;
}
this.file = file;
this.fileRenderer.setOptions({
...this.options,
Expand Down Expand Up @@ -1115,7 +1123,8 @@ export class File<LAnnotation = undefined> {
this.cleanupErrorWrapper();
this.placeHolder?.remove();
this.placeHolder = undefined;
const headerHTML = toHtml(headerAST);
const headerHTML = this.cachedHeaderHTML ?? toHtml(headerAST);
this.cachedHeaderHTML = headerHTML;
if (headerHTML !== this.lastRenderedHeaderHTML) {
const tempDiv = document.createElement('div');
tempDiv.innerHTML = headerHTML;
Expand Down
11 changes: 10 additions & 1 deletion packages/diffs/src/components/FileDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export class FileDiff<LAnnotation = undefined> {
protected renderRange: RenderRange | undefined;
protected appliedPreAttributes: PrePropertiesConfig | undefined;
protected lastRenderedHeaderHTML: string | undefined;
protected cachedHeaderHTML: string | undefined;
protected lastRowCount: number | undefined;

protected enabled = true;
Expand Down Expand Up @@ -356,6 +357,7 @@ export class FileDiff<LAnnotation = undefined> {
public setOptions(options: FileDiffOptions<LAnnotation> | undefined): void {
if (options == null) return;
this.options = options;
this.cachedHeaderHTML = undefined;
this.hunksRenderer.setOptions(this.getHunksRendererOptions(options));
this.interactionManager.setOptions(
pluckInteractionOptions(
Expand Down Expand Up @@ -496,6 +498,9 @@ export class FileDiff<LAnnotation = undefined> {
this.headerCustom = undefined;
this.placeHolder = undefined;
this.lastRenderedHeaderHTML = undefined;
if (!recycle) {
this.cachedHeaderHTML = undefined;
}
this.errorWrapper = undefined;
this.spriteSVG = undefined;
this.lastRowCount = undefined;
Expand Down Expand Up @@ -758,6 +763,9 @@ export class FileDiff<LAnnotation = undefined> {
this.options.parseDiffOptions
);
}
if (diffDidChange) {
this.cachedHeaderHTML = undefined;
}

if (lineAnnotations != null) {
this.setLineAnnotations(lineAnnotations);
Expand Down Expand Up @@ -1214,7 +1222,8 @@ export class FileDiff<LAnnotation = undefined> {
this.placeHolder?.remove();
this.placeHolder = undefined;
const { fileDiff } = this;
const headerHTML = toHtml(headerAST);
const headerHTML = this.cachedHeaderHTML ?? toHtml(headerAST);
this.cachedHeaderHTML = headerHTML;
if (headerHTML !== this.lastRenderedHeaderHTML) {
const tempDiv = document.createElement('div');
tempDiv.innerHTML = headerHTML;
Expand Down
Loading