@pierre/diffs 1.2.10 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +6 -6
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +6 -1
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +1 -1
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.js +4 -2
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +6 -2
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +82 -21
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +7 -2
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +77 -15
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/managers/InteractionManager.js +1 -1
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/ResizeManager.js +1 -1
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +3 -2
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +49 -2
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.js +12 -0
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/includesFileAnnotations.d.ts +17 -0
- package/dist/utils/includesFileAnnotations.d.ts.map +1 -0
- package/dist/utils/includesFileAnnotations.js +19 -0
- package/dist/utils/includesFileAnnotations.js.map +1 -0
- package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +4 -2
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +4 -2
- package/dist/utils/renderFileWithHighlighter.js.map +1 -1
- package/dist/worker/worker-portable.js +8 -4
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +8 -4
- package/dist/worker/worker.js.map +1 -1
- package/package.json +2 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExpansionDirections, FileDiffMetadata, NumericScrollLineAnchor, PendingCodeViewLayoutReset, RenderWindow, SelectionSide, StickySpecs, ThemeTypes, VirtualFileMetrics } from "../types.js";
|
|
1
|
+
import { DiffLineAnnotation, ExpansionDirections, FileDiffMetadata, NumericScrollLineAnchor, PendingCodeViewLayoutReset, RenderWindow, SelectionSide, StickySpecs, ThemeTypes, VirtualFileMetrics } from "../types.js";
|
|
2
2
|
import { WorkerPoolManager } from "../worker/WorkerPoolManager.js";
|
|
3
3
|
import "../worker/index.js";
|
|
4
4
|
import { Virtualizer } from "./Virtualizer.js";
|
|
@@ -20,6 +20,10 @@ declare class VirtualizedFileDiff<LAnnotation = undefined> extends FileDiff<LAnn
|
|
|
20
20
|
private currentCollapsed;
|
|
21
21
|
constructor(options: FileDiffOptions<LAnnotation> | undefined, virtualizer: Virtualizer | CodeView<LAnnotation>, metrics?: Partial<VirtualFileMetrics>, workerManager?: WorkerPoolManager, isContainerManaged?: boolean);
|
|
22
22
|
setMetrics(metrics?: Partial<VirtualFileMetrics>, force?: boolean): void;
|
|
23
|
+
setLineAnnotations(lineAnnotations: DiffLineAnnotation<LAnnotation>[]): void;
|
|
24
|
+
private syncLineAnnotations;
|
|
25
|
+
private setFileAnnotationHeight;
|
|
26
|
+
private hasFileAnnotations;
|
|
23
27
|
private getLineHeight;
|
|
24
28
|
private getEstimatedLineHeight;
|
|
25
29
|
setOptions(options: FileDiffOptions<LAnnotation> | undefined): void;
|
|
@@ -27,7 +31,7 @@ declare class VirtualizedFileDiff<LAnnotation = undefined> extends FileDiff<LAnn
|
|
|
27
31
|
private resetLayoutCache;
|
|
28
32
|
reconcileHeights(): boolean;
|
|
29
33
|
onRender: (dirty: boolean) => boolean;
|
|
30
|
-
prepareCodeViewItem(fileDiff: FileDiffMetadata, top: number, reset?: PendingCodeViewLayoutReset): number;
|
|
34
|
+
prepareCodeViewItem(fileDiff: FileDiffMetadata, top: number, reset?: PendingCodeViewLayoutReset, lineAnnotations?: DiffLineAnnotation<LAnnotation>[]): number;
|
|
31
35
|
getLinePosition(lineNumber: number, side?: SelectionSide): {
|
|
32
36
|
top: number;
|
|
33
37
|
height: number;
|
|
@@ -49,6 +53,7 @@ declare class VirtualizedFileDiff<LAnnotation = undefined> extends FileDiff<LAnn
|
|
|
49
53
|
newFile,
|
|
50
54
|
fileDiff,
|
|
51
55
|
forceRender,
|
|
56
|
+
lineAnnotations,
|
|
52
57
|
...props
|
|
53
58
|
}?: FileDiffRenderProps<LAnnotation>): boolean;
|
|
54
59
|
syncVirtualizedTop(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualizedFileDiff.d.ts","names":["ExpansionDirections","FileDiffMetadata","NumericScrollLineAnchor","PendingCodeViewLayoutReset","RenderWindow","SelectionSide","StickySpecs","ThemeTypes","VirtualFileMetrics","WorkerPoolManager","CodeView","FileDiff","FileDiffOptions","FileDiffRenderProps","Virtualizer","VirtualizedFileDiff","LAnnotation","Partial","fileContainer","oldFile","newFile","fileDiff","forceRender"],"sources":["../../src/components/VirtualizedFileDiff.d.ts"],"sourcesContent":["import type { ExpansionDirections, FileDiffMetadata, NumericScrollLineAnchor, PendingCodeViewLayoutReset, RenderWindow, SelectionSide, StickySpecs, ThemeTypes, VirtualFileMetrics } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nimport type { CodeView } from './CodeView';\nimport { FileDiff, type FileDiffOptions, type FileDiffRenderProps } from './FileDiff';\nimport type { Virtualizer } from './Virtualizer';\nexport declare class VirtualizedFileDiff<LAnnotation = undefined> extends FileDiff<LAnnotation> {\n readonly __id: string;\n top: number | undefined;\n height: number;\n private metrics;\n private cache;\n private isVisible;\n private isSetup;\n private virtualizer;\n private layoutDirty;\n private forceRenderOverride;\n private currentCollapsed;\n constructor(options: FileDiffOptions<LAnnotation> | undefined, virtualizer: Virtualizer | CodeView<LAnnotation>, metrics?: Partial<VirtualFileMetrics>, workerManager?: WorkerPoolManager, isContainerManaged?: boolean);\n setMetrics(metrics?: Partial<VirtualFileMetrics>, force?: boolean): void;\n private getLineHeight;\n private getEstimatedLineHeight;\n setOptions(options: FileDiffOptions<LAnnotation> | undefined): void;\n setThemeType(themeType: ThemeTypes): void;\n private resetLayoutCache;\n reconcileHeights(): boolean;\n onRender: (dirty: boolean) => boolean;\n prepareCodeViewItem(fileDiff: FileDiffMetadata, top: number, reset?: PendingCodeViewLayoutReset): number;\n getLinePosition(lineNumber: number, side?: SelectionSide): {\n top: number;\n height: number;\n } | undefined;\n getNumericScrollAnchor(localViewportTop: number): NumericScrollLineAnchor | undefined;\n getVirtualizedHeight(): number;\n getAdvancedStickySpecs(windowSpecs?: RenderWindow): StickySpecs | undefined;\n cleanUp(recycle?: boolean): void;\n expandHunk: (hunkIndex: number, direction: ExpansionDirections, expansionLineCountOverride?: number | undefined) => void;\n setVisibility(visible: boolean): void;\n rerender(): void;\n private computeApproximateSize;\n private getActiveEstimatedHeight;\n private ensureEstimatedDiffHeights;\n private validateComputedHeight;\n render({ fileContainer, oldFile, newFile, fileDiff, forceRender, ...props }?: FileDiffRenderProps<LAnnotation>): boolean;\n syncVirtualizedTop(): void;\n protected shouldDisableVirtualizationBuffers(): boolean;\n private isSimpleMode;\n private isAdvancedMode;\n private getVirtualizedTop;\n private getSimpleVirtualizer;\n private isResizeDebuggingEnabled;\n private getDiffStyle;\n private getHunkSeparatorType;\n private approximateLayoutCheckpoints;\n private getLayoutCheckpointBeforeLineIndex;\n private getLayoutCheckpointBeforeTop;\n private getExpandedLineCount;\n private computeRenderRangeFromWindow;\n}\n//# sourceMappingURL=VirtualizedFileDiff.d.ts.map"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"VirtualizedFileDiff.d.ts","names":["DiffLineAnnotation","ExpansionDirections","FileDiffMetadata","NumericScrollLineAnchor","PendingCodeViewLayoutReset","RenderWindow","SelectionSide","StickySpecs","ThemeTypes","VirtualFileMetrics","WorkerPoolManager","CodeView","FileDiff","FileDiffOptions","FileDiffRenderProps","Virtualizer","VirtualizedFileDiff","LAnnotation","Partial","fileContainer","oldFile","newFile","fileDiff","forceRender","lineAnnotations"],"sources":["../../src/components/VirtualizedFileDiff.d.ts"],"sourcesContent":["import type { DiffLineAnnotation, ExpansionDirections, FileDiffMetadata, NumericScrollLineAnchor, PendingCodeViewLayoutReset, RenderWindow, SelectionSide, StickySpecs, ThemeTypes, VirtualFileMetrics } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nimport type { CodeView } from './CodeView';\nimport { FileDiff, type FileDiffOptions, type FileDiffRenderProps } from './FileDiff';\nimport type { Virtualizer } from './Virtualizer';\nexport declare class VirtualizedFileDiff<LAnnotation = undefined> extends FileDiff<LAnnotation> {\n readonly __id: string;\n top: number | undefined;\n height: number;\n private metrics;\n private cache;\n private isVisible;\n private isSetup;\n private virtualizer;\n private layoutDirty;\n private forceRenderOverride;\n private currentCollapsed;\n constructor(options: FileDiffOptions<LAnnotation> | undefined, virtualizer: Virtualizer | CodeView<LAnnotation>, metrics?: Partial<VirtualFileMetrics>, workerManager?: WorkerPoolManager, isContainerManaged?: boolean);\n setMetrics(metrics?: Partial<VirtualFileMetrics>, force?: boolean): void;\n setLineAnnotations(lineAnnotations: DiffLineAnnotation<LAnnotation>[]): void;\n private syncLineAnnotations;\n private setFileAnnotationHeight;\n private hasFileAnnotations;\n private getLineHeight;\n private getEstimatedLineHeight;\n setOptions(options: FileDiffOptions<LAnnotation> | undefined): void;\n setThemeType(themeType: ThemeTypes): void;\n private resetLayoutCache;\n reconcileHeights(): boolean;\n onRender: (dirty: boolean) => boolean;\n prepareCodeViewItem(fileDiff: FileDiffMetadata, top: number, reset?: PendingCodeViewLayoutReset, lineAnnotations?: DiffLineAnnotation<LAnnotation>[]): number;\n getLinePosition(lineNumber: number, side?: SelectionSide): {\n top: number;\n height: number;\n } | undefined;\n getNumericScrollAnchor(localViewportTop: number): NumericScrollLineAnchor | undefined;\n getVirtualizedHeight(): number;\n getAdvancedStickySpecs(windowSpecs?: RenderWindow): StickySpecs | undefined;\n cleanUp(recycle?: boolean): void;\n expandHunk: (hunkIndex: number, direction: ExpansionDirections, expansionLineCountOverride?: number | undefined) => void;\n setVisibility(visible: boolean): void;\n rerender(): void;\n private computeApproximateSize;\n private getActiveEstimatedHeight;\n private ensureEstimatedDiffHeights;\n private validateComputedHeight;\n render({ fileContainer, oldFile, newFile, fileDiff, forceRender, lineAnnotations, ...props }?: FileDiffRenderProps<LAnnotation>): boolean;\n syncVirtualizedTop(): void;\n protected shouldDisableVirtualizationBuffers(): boolean;\n private isSimpleMode;\n private isAdvancedMode;\n private getVirtualizedTop;\n private getSimpleVirtualizer;\n private isResizeDebuggingEnabled;\n private getDiffStyle;\n private getHunkSeparatorType;\n private approximateLayoutCheckpoints;\n private getLayoutCheckpointBeforeLineIndex;\n private getLayoutCheckpointBeforeTop;\n private getExpandedLineCount;\n private computeRenderRangeFromWindow;\n}\n//# sourceMappingURL=VirtualizedFileDiff.d.ts.map"],"mappings":";;;;;;;;cAKqBgB,qDAAqDJ,SAASK;;;EAA9DD,MAAAA,EAAAA,MAAAA;EAA8DC,QAAAA,OAAAA;EAY1CA,QAAAA,KAAAA;EAAhBJ,QAAAA,SAAAA;EAAuDE,QAAAA,OAAAA;EAAuBE,QAAAA,WAAAA;EAATN,QAAAA,WAAAA;EAAyCF,QAAAA,mBAAAA;EAARS,QAAAA,gBAAAA;EAA6CR,WAAAA,CAAAA,OAAAA,EAAnJG,eAAmJH,CAAnIO,WAAmIP,CAAAA,GAAAA,SAAAA,EAAAA,WAAAA,EAA5FK,WAA4FL,GAA9EC,QAA8ED,CAArEO,WAAqEP,CAAAA,EAAAA,OAAAA,CAAAA,EAA7CQ,OAA6CR,CAArCD,kBAAqCC,CAAAA,EAAAA,aAAAA,CAAAA,EAAAA,iBAAAA,EAAAA,kBAAAA,CAAAA,EAAAA,OAAAA;EAC3ID,UAAAA,CAAAA,OAAAA,CAAAA,EAARS,OAAQT,CAAAA,kBAAAA,CAAAA,EAAAA,KAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,IAAAA;EAARS,kBAAAA,CAAAA,eAAAA,EACelB,kBADfkB,CACkCD,WADlCC,CAAAA,EAAAA,CAAAA,EAAAA,IAAAA;EACkCD,QAAAA,mBAAAA;EAAnBjB,QAAAA,uBAAAA;EAMAiB,QAAAA,kBAAAA;EAAhBJ,QAAAA,aAAAA;EACIL,QAAAA,sBAAAA;EAIMN,UAAAA,CAAAA,OAAAA,EALVW,eAKUX,CALMe,WAKNf,CAAAA,GAAAA,SAAAA,CAAAA,EAAAA,IAAAA;EAAuCE,YAAAA,CAAAA,SAAAA,EAJ7CI,UAI6CJ,CAAAA,EAAAA,IAAAA;EAAiEa,QAAAA,gBAAAA;EAAnBjB,gBAAAA,CAAAA,CAAAA,EAAAA,OAAAA;EACxEM,QAAAA,EAAAA,CAAAA,KAAAA,EAAAA,OAAAA,EAAAA,GAAAA,OAAAA;EAIOH,mBAAAA,CAAAA,QAAAA,EALpBD,gBAKoBC,EAAAA,GAAAA,EAAAA,MAAAA,EAAAA,KAAAA,CAAAA,EALmBC,0BAKnBD,EAAAA,eAAAA,CAAAA,EALiEH,kBAKjEG,CALoFc,WAKpFd,CAAAA,EAAAA,CAAAA,EAAAA,MAAAA;EAEbE,eAAAA,CAAAA,UAAAA,EAAAA,MAAAA,EAAAA,IAAAA,CAAAA,EANMC,aAMND,CAAAA,EAAAA;IAAeE,GAAAA,EAAAA,MAAAA;IAETN,MAAAA,EAAAA,MAAAA;EAOlCkB,CAAAA,GAAAA,SAAAA;EAAeC,sBAAAA,CAAAA,gBAAAA,EAAAA,MAAAA,CAAAA,EAX0BjB,uBAW1BiB,GAAAA,SAAAA;EAASC,oBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAASC,sBAAAA,CAAAA,WAAAA,CAAAA,EATLjB,YASKiB,CAAAA,EATUf,WASVe,GAAAA,SAAAA;EAAUC,OAAAA,CAAAA,OAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,IAAAA;EAAaC,UAAAA,EAAAA,CAAAA,SAAAA,EAAAA,MAAAA,EAAAA,SAAAA,EAPtBvB,mBAOsBuB,EAAAA,0BAAAA,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA,EAAAA,GAAAA,IAAAA;EAAkDP,aAAAA,CAAAA,OAAAA,EAAAA,OAAAA,CAAAA,EAAAA,IAAAA;EAApBH,QAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EAzCzBF,QAAAA,sBAAAA;EAAQ,QAAA,wBAAA;;;;;;;;;;;MAyCiBE,oBAAoBG"}
|
|
@@ -2,6 +2,7 @@ import { DEFAULT_COLLAPSED_CONTEXT_THRESHOLD } from "../constants.js";
|
|
|
2
2
|
import { areObjectsEqual } from "../utils/areObjectsEqual.js";
|
|
3
3
|
import { areOptionsEqual } from "../utils/areOptionsEqual.js";
|
|
4
4
|
import { computeVirtualFileMetrics, getVirtualFileHeaderRegion, getVirtualFilePaddingBottom } from "../utils/computeVirtualFileMetrics.js";
|
|
5
|
+
import { FILE_ANNOTATION_DOM_KEY, FILE_ANNOTATION_LINE_NUMBER, includesFileAnnotations, shouldRenderFileAnnotations } from "../utils/includesFileAnnotations.js";
|
|
5
6
|
import { areDiffTargetsEqual } from "../utils/areDiffTargetsEqual.js";
|
|
6
7
|
import { getExpandedRegion, getLeadingHunkSeparatorLayout, getTrailingExpandedRegion, getTrailingHunkSeparatorLayout } from "../utils/virtualDiffLayout.js";
|
|
7
8
|
import { computeEstimatedDiffHeights } from "../utils/computeEstimatedDiffHeights.js";
|
|
@@ -23,7 +24,8 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
23
24
|
estimatedSplitHeight: void 0,
|
|
24
25
|
estimatedUnifiedHeight: void 0,
|
|
25
26
|
checkpoints: [],
|
|
26
|
-
totalLines: 0
|
|
27
|
+
totalLines: 0,
|
|
28
|
+
fileAnnotationHeight: 0
|
|
27
29
|
};
|
|
28
30
|
isVisible = false;
|
|
29
31
|
isSetup = false;
|
|
@@ -42,6 +44,30 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
42
44
|
this.metrics = nextMetrics;
|
|
43
45
|
this.resetLayoutCache({ includeEstimatedHeights: true });
|
|
44
46
|
}
|
|
47
|
+
setLineAnnotations(lineAnnotations) {
|
|
48
|
+
if (this.syncLineAnnotations(lineAnnotations)) this.resetLayoutCache({ includeEstimatedHeights: false });
|
|
49
|
+
}
|
|
50
|
+
syncLineAnnotations(lineAnnotations) {
|
|
51
|
+
if (lineAnnotations == null || lineAnnotations === this.lineAnnotations || lineAnnotations.length === 0 && this.lineAnnotations.length === 0) return false;
|
|
52
|
+
super.setLineAnnotations(lineAnnotations);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
setFileAnnotationHeight(nextHeight) {
|
|
56
|
+
const previousHeight = this.cache.fileAnnotationHeight;
|
|
57
|
+
if (nextHeight === previousHeight) return false;
|
|
58
|
+
this.cache.fileAnnotationHeight = nextHeight;
|
|
59
|
+
this.cache.measuredHeightDeltaTotal += nextHeight - previousHeight;
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
hasFileAnnotations(fileDiff = this.fileDiff) {
|
|
63
|
+
if (fileDiff == null || !includesFileAnnotations(this.lineAnnotations)) return false;
|
|
64
|
+
return this.lineAnnotations.some((annotation) => {
|
|
65
|
+
if (annotation.lineNumber !== FILE_ANNOTATION_LINE_NUMBER) return false;
|
|
66
|
+
if (fileDiff.type === "new") return annotation.side === "additions";
|
|
67
|
+
if (fileDiff.type === "deleted") return annotation.side === "deletions";
|
|
68
|
+
return true;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
45
71
|
getLineHeight(lineIndex, hasMetadataLine = false) {
|
|
46
72
|
return this.getEstimatedLineHeight(hasMetadataLine) + (this.cache.heightDeltas.get(lineIndex) ?? 0);
|
|
47
73
|
}
|
|
@@ -69,6 +95,7 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
69
95
|
}
|
|
70
96
|
resetLayoutCache({ forceSimpleRecompute = false, includeEstimatedHeights = false } = {}) {
|
|
71
97
|
this.layoutDirty = true;
|
|
98
|
+
this.cache.fileAnnotationHeight = 0;
|
|
72
99
|
if (this.cache.heightDeltas.size > 0) this.cache.heightDeltas.clear();
|
|
73
100
|
if (this.cache.measuredHeightDeltaTotal !== 0) this.cache.measuredHeightDeltaTotal = 0;
|
|
74
101
|
if (this.cache.checkpoints.length > 0) this.cache.checkpoints.length = 0;
|
|
@@ -92,6 +119,11 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
92
119
|
if (overflow === "scroll" && this.lineAnnotations.length === 0 && !this.isResizeDebuggingEnabled()) return hasHeightChange;
|
|
93
120
|
const diffStyle = this.getDiffStyle();
|
|
94
121
|
const codeGroups = diffStyle === "split" ? [this.codeDeletions, this.codeAdditions] : [this.codeUnified];
|
|
122
|
+
const hasFileAnnotations = this.hasFileAnnotations(this.fileDiff);
|
|
123
|
+
if (this.renderRange != null && hasFileAnnotations && shouldRenderFileAnnotations(this.renderRange)) {
|
|
124
|
+
const nextFileAnnotationHeight = measureFileAnnotationHeight(codeGroups) ?? 0;
|
|
125
|
+
if (this.setFileAnnotationHeight(nextFileAnnotationHeight)) hasHeightChange = true;
|
|
126
|
+
} else if (!hasFileAnnotations && this.setFileAnnotationHeight(0)) hasHeightChange = true;
|
|
95
127
|
for (const codeGroup of codeGroups) {
|
|
96
128
|
if (codeGroup == null) continue;
|
|
97
129
|
const content = codeGroup.children[1];
|
|
@@ -125,9 +157,10 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
125
157
|
if (dirty) this.top = this.getVirtualizedTop();
|
|
126
158
|
return this.render();
|
|
127
159
|
};
|
|
128
|
-
prepareCodeViewItem(fileDiff, top, reset) {
|
|
160
|
+
prepareCodeViewItem(fileDiff, top, reset, lineAnnotations) {
|
|
129
161
|
const targetChanged = !areDiffTargetsEqual(this.fileDiff, fileDiff);
|
|
130
|
-
|
|
162
|
+
const annotationsChanged = this.syncLineAnnotations(lineAnnotations);
|
|
163
|
+
let shouldResetLayoutCache = reset?.resetDiffLayoutCache === true || targetChanged || annotationsChanged;
|
|
131
164
|
let includeEstimatedHeights = targetChanged || reset?.resetDiffLayoutCache === true && reset.includeEstimatedDiffHeights;
|
|
132
165
|
if (reset?.metrics != null) {
|
|
133
166
|
this.metrics = computeVirtualFileMetrics(reset.metrics);
|
|
@@ -146,7 +179,7 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
146
179
|
return this.height;
|
|
147
180
|
}
|
|
148
181
|
getLinePosition(lineNumber, side = "additions") {
|
|
149
|
-
if (this.fileDiff == null) return;
|
|
182
|
+
if (this.fileDiff == null || lineNumber < 1) return;
|
|
150
183
|
const targetLineIndexes = this.getLineIndex(lineNumber, side);
|
|
151
184
|
if (targetLineIndexes == null) return;
|
|
152
185
|
const { disableFileHeader = false, expandUnchanged = false, collapsed = false, collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD } = this.options;
|
|
@@ -154,10 +187,11 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
154
187
|
const hunkSeparators = this.getHunkSeparatorType();
|
|
155
188
|
const targetLineIndex = diffStyle === "split" ? targetLineIndexes[1] : targetLineIndexes[0];
|
|
156
189
|
this.approximateLayoutCheckpoints();
|
|
190
|
+
const headerRegion = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
|
|
157
191
|
const checkpoint = this.getLayoutCheckpointBeforeLineIndex(targetLineIndex);
|
|
158
|
-
let top = checkpoint?.top ??
|
|
192
|
+
let top = checkpoint?.top ?? headerRegion + this.cache.fileAnnotationHeight;
|
|
159
193
|
if (collapsed) return {
|
|
160
|
-
top,
|
|
194
|
+
top: headerRegion,
|
|
161
195
|
height: 0
|
|
162
196
|
};
|
|
163
197
|
let position;
|
|
@@ -227,7 +261,7 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
227
261
|
const hunkSeparators = this.getHunkSeparatorType();
|
|
228
262
|
this.approximateLayoutCheckpoints();
|
|
229
263
|
const checkpoint = this.getLayoutCheckpointBeforeTop(localViewportTop);
|
|
230
|
-
let top = checkpoint?.top ?? getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
|
|
264
|
+
let top = checkpoint?.top ?? getVirtualFileHeaderRegion(this.metrics, disableFileHeader) + this.cache.fileAnnotationHeight;
|
|
231
265
|
let anchor;
|
|
232
266
|
iterateOverDiff({
|
|
233
267
|
diff: this.fileDiff,
|
|
@@ -383,9 +417,11 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
383
417
|
});
|
|
384
418
|
else console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT");
|
|
385
419
|
}
|
|
386
|
-
render({ fileContainer, oldFile, newFile, fileDiff, forceRender = false,...props } = {}) {
|
|
420
|
+
render({ fileContainer, oldFile, newFile, fileDiff, forceRender = false, lineAnnotations,...props } = {}) {
|
|
387
421
|
const { forceRenderOverride, isSetup } = this;
|
|
388
422
|
this.forceRenderOverride = void 0;
|
|
423
|
+
const annotationsChanged = this.syncLineAnnotations(lineAnnotations);
|
|
424
|
+
if (annotationsChanged) this.resetLayoutCache({ includeEstimatedHeights: false });
|
|
389
425
|
this.fileDiff ??= fileDiff ?? (oldFile != null && newFile != null ? parseDiffFromFile(oldFile, newFile, this.options.parseDiffOptions) : void 0);
|
|
390
426
|
fileContainer = this.getOrCreateFileContainer(fileContainer);
|
|
391
427
|
if (this.fileDiff == null) {
|
|
@@ -414,7 +450,8 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
414
450
|
renderRange,
|
|
415
451
|
oldFile,
|
|
416
452
|
newFile,
|
|
417
|
-
|
|
453
|
+
lineAnnotations,
|
|
454
|
+
forceRender: (forceRenderOverride ?? forceRender) || annotationsChanged,
|
|
418
455
|
...props
|
|
419
456
|
});
|
|
420
457
|
}
|
|
@@ -454,7 +491,7 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
454
491
|
const hunkSeparators = this.getHunkSeparatorType();
|
|
455
492
|
const expandedHunks = expandUnchanged ? true : this.hunksRenderer.getExpandedHunksMap();
|
|
456
493
|
const heightDeltaPrefix = createHeightDeltaPrefix(this.cache.heightDeltas);
|
|
457
|
-
let top = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
|
|
494
|
+
let top = getVirtualFileHeaderRegion(this.metrics, disableFileHeader) + this.cache.fileAnnotationHeight;
|
|
458
495
|
let renderedLineIndex = 0;
|
|
459
496
|
const processRows = ({ rowCount, startLineIndex, preSeparatorHeight = 0, postSeparatorHeight = 0, metadataOffsets = [] }) => {
|
|
460
497
|
if (rowCount <= 0) return;
|
|
@@ -610,6 +647,12 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
610
647
|
let lineCount = this.cache.totalLines > 0 ? this.cache.totalLines : this.getExpandedLineCount(fileDiff, diffStyle);
|
|
611
648
|
const headerRegion = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
|
|
612
649
|
const paddingBottom = fileDiff.hunks.length > 0 ? getVirtualFilePaddingBottom(this.metrics) : 0;
|
|
650
|
+
const { fileAnnotationHeight } = this.cache;
|
|
651
|
+
const codeRegionTop = headerRegion + fileAnnotationHeight;
|
|
652
|
+
const codeHeight = Math.max(0, fileHeight - headerRegion - fileAnnotationHeight - paddingBottom);
|
|
653
|
+
const hasFileAnnotations = this.hasFileAnnotations(fileDiff);
|
|
654
|
+
const fileAnnotationTop = fileTop + headerRegion;
|
|
655
|
+
const measuredFileAnnotationVisible = fileAnnotationHeight > 0 && hasFileAnnotations && fileAnnotationTop < bottom && fileAnnotationTop + fileAnnotationHeight > top;
|
|
613
656
|
if (fileTop < top - fileHeight || fileTop > bottom) return {
|
|
614
657
|
startingLine: 0,
|
|
615
658
|
totalLines: 0,
|
|
@@ -631,7 +674,7 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
631
674
|
const hunkOffsets = [];
|
|
632
675
|
const viewportCenter = (top + bottom) / 2;
|
|
633
676
|
const checkpoint = this.getLayoutCheckpointBeforeTop(Math.max(0, top - fileTop - totalLines * lineHeight * 2), hunkLineCount);
|
|
634
|
-
let absoluteLineTop = fileTop + (checkpoint?.top ??
|
|
677
|
+
let absoluteLineTop = fileTop + (checkpoint?.top ?? codeRegionTop);
|
|
635
678
|
let currentLine = checkpoint?.renderedLineIndex ?? 0;
|
|
636
679
|
let firstVisibleHunk;
|
|
637
680
|
let centerHunk;
|
|
@@ -656,7 +699,7 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
656
699
|
const isAtHunkBoundary = currentLine % hunkLineCount === 0;
|
|
657
700
|
const currentHunk = Math.floor(currentLine / hunkLineCount);
|
|
658
701
|
if (isAtHunkBoundary) {
|
|
659
|
-
hunkOffsets[currentHunk] = absoluteLineTop - (fileTop +
|
|
702
|
+
hunkOffsets[currentHunk] = absoluteLineTop - (fileTop + codeRegionTop + gapAdjustment);
|
|
660
703
|
if (overflowCounter != null) {
|
|
661
704
|
if (overflowCounter <= 0) return true;
|
|
662
705
|
overflowCounter--;
|
|
@@ -675,7 +718,10 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
675
718
|
return false;
|
|
676
719
|
}
|
|
677
720
|
});
|
|
678
|
-
if (firstVisibleHunk == null)
|
|
721
|
+
if (firstVisibleHunk == null) if (measuredFileAnnotationVisible) {
|
|
722
|
+
firstVisibleHunk = 0;
|
|
723
|
+
centerHunk = 0;
|
|
724
|
+
} else return {
|
|
679
725
|
startingLine: 0,
|
|
680
726
|
totalLines: 0,
|
|
681
727
|
bufferBefore: 0,
|
|
@@ -687,16 +733,32 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
687
733
|
const startHunk = Math.max(0, Math.min(idealStartHunk, maxStartHunk));
|
|
688
734
|
const startingLine = startHunk * hunkLineCount;
|
|
689
735
|
const clampedTotalLines = idealStartHunk < 0 ? totalLines + idealStartHunk * hunkLineCount : totalLines;
|
|
690
|
-
const
|
|
736
|
+
const codeBufferBefore = hunkOffsets[startHunk] ?? 0;
|
|
737
|
+
const bufferBefore = startingLine === 0 ? 0 : fileAnnotationHeight + codeBufferBefore;
|
|
691
738
|
const finalHunkIndex = startHunk + clampedTotalLines / hunkLineCount;
|
|
739
|
+
const bufferAfter = finalHunkIndex < hunkOffsets.length ? codeHeight - hunkOffsets[finalHunkIndex] : codeHeight - (absoluteLineTop - fileTop - codeRegionTop);
|
|
692
740
|
return {
|
|
693
741
|
startingLine,
|
|
694
742
|
totalLines: clampedTotalLines,
|
|
695
743
|
bufferBefore,
|
|
696
|
-
bufferAfter:
|
|
744
|
+
bufferAfter: Math.max(0, bufferAfter)
|
|
697
745
|
};
|
|
698
746
|
}
|
|
699
747
|
};
|
|
748
|
+
function measureFileAnnotationHeight(codeGroups) {
|
|
749
|
+
let height;
|
|
750
|
+
for (const codeGroup of codeGroups) {
|
|
751
|
+
if (codeGroup == null) continue;
|
|
752
|
+
const content = codeGroup.children[1];
|
|
753
|
+
if (!(content instanceof HTMLElement)) continue;
|
|
754
|
+
for (const child of content.children) {
|
|
755
|
+
if (!(child instanceof HTMLElement)) continue;
|
|
756
|
+
if (child.dataset.lineAnnotation !== FILE_ANNOTATION_DOM_KEY) continue;
|
|
757
|
+
height = Math.max(height ?? 0, child.getBoundingClientRect().height);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
return height;
|
|
761
|
+
}
|
|
700
762
|
function createHeightDeltaPrefix(heightDeltas) {
|
|
701
763
|
const entries = Array.from(heightDeltas).sort((a, b) => a[0] - b[0]);
|
|
702
764
|
const lineIndexes = [];
|