@pierre/diffs 1.2.12 → 1.3.0-beta.10
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/dist/components/CodeView.d.ts +91 -6
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +300 -38
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts +14 -3
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +98 -12
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +68 -19
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +363 -25
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.d.ts.map +1 -1
- package/dist/components/FileStream.js +2 -1
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +2 -2
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js +2 -2
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +4 -2
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +59 -47
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +27 -5
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +262 -56
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.d.ts +4 -1
- package/dist/components/Virtualizer.d.ts.map +1 -1
- package/dist/components/Virtualizer.js +21 -4
- package/dist/components/Virtualizer.js.map +1 -1
- package/dist/constants.d.ts +4 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -1
- package/dist/constants.js.map +1 -1
- package/dist/editor/command.d.ts +7 -0
- package/dist/editor/command.d.ts.map +1 -0
- package/dist/editor/command.js +54 -0
- package/dist/editor/command.js.map +1 -0
- package/dist/editor/editStack.d.ts +71 -0
- package/dist/editor/editStack.d.ts.map +1 -0
- package/dist/editor/editStack.js +218 -0
- package/dist/editor/editStack.js.map +1 -0
- package/dist/editor/editor.d.ts +105 -0
- package/dist/editor/editor.d.ts.map +1 -0
- package/dist/editor/editor.js +2545 -0
- package/dist/editor/editor.js.map +1 -0
- package/dist/editor/editor2.js +6 -0
- package/dist/editor/editor2.js.map +1 -0
- package/dist/editor/index.d.ts +5 -0
- package/dist/editor/index.js +3 -0
- package/dist/editor/languages.d.ts +26 -0
- package/dist/editor/languages.d.ts.map +1 -0
- package/dist/editor/languages.js +363 -0
- package/dist/editor/languages.js.map +1 -0
- package/dist/editor/lineAnnotations.d.ts +9 -0
- package/dist/editor/lineAnnotations.d.ts.map +1 -0
- package/dist/editor/lineAnnotations.js +212 -0
- package/dist/editor/lineAnnotations.js.map +1 -0
- package/dist/editor/marker.d.ts +38 -0
- package/dist/editor/marker.d.ts.map +1 -0
- package/dist/editor/marker.js +245 -0
- package/dist/editor/marker.js.map +1 -0
- package/dist/editor/matchBrackets.d.ts +9 -0
- package/dist/editor/matchBrackets.d.ts.map +1 -0
- package/dist/editor/matchBrackets.js +138 -0
- package/dist/editor/matchBrackets.js.map +1 -0
- package/dist/editor/pieceTable.d.ts +41 -0
- package/dist/editor/pieceTable.d.ts.map +1 -0
- package/dist/editor/pieceTable.js +671 -0
- package/dist/editor/pieceTable.js.map +1 -0
- package/dist/editor/platform.d.ts +19 -0
- package/dist/editor/platform.d.ts.map +1 -0
- package/dist/editor/platform.js +57 -0
- package/dist/editor/platform.js.map +1 -0
- package/dist/editor/popover.d.ts +65 -0
- package/dist/editor/popover.d.ts.map +1 -0
- package/dist/editor/popover.js +187 -0
- package/dist/editor/popover.js.map +1 -0
- package/dist/editor/searchPanel.d.ts +40 -0
- package/dist/editor/searchPanel.d.ts.map +1 -0
- package/dist/editor/searchPanel.js +318 -0
- package/dist/editor/searchPanel.js.map +1 -0
- package/dist/editor/selection.d.ts +211 -0
- package/dist/editor/selection.d.ts.map +1 -0
- package/dist/editor/selection.js +1626 -0
- package/dist/editor/selection.js.map +1 -0
- package/dist/editor/selectionAction.d.ts +46 -0
- package/dist/editor/selectionAction.d.ts.map +1 -0
- package/dist/editor/selectionAction.js +64 -0
- package/dist/editor/selectionAction.js.map +1 -0
- package/dist/editor/sprite.d.ts +8 -0
- package/dist/editor/sprite.d.ts.map +1 -0
- package/dist/editor/sprite.js +45 -0
- package/dist/editor/sprite.js.map +1 -0
- package/dist/editor/stateStorage.d.ts +15 -0
- package/dist/editor/stateStorage.d.ts.map +1 -0
- package/dist/editor/stateStorage.js +65 -0
- package/dist/editor/stateStorage.js.map +1 -0
- package/dist/editor/textDocument.d.ts +77 -0
- package/dist/editor/textDocument.d.ts.map +1 -0
- package/dist/editor/textDocument.js +271 -0
- package/dist/editor/textDocument.js.map +1 -0
- package/dist/editor/textMeasure.d.ts +61 -0
- package/dist/editor/textMeasure.d.ts.map +1 -0
- package/dist/editor/textMeasure.js +209 -0
- package/dist/editor/textMeasure.js.map +1 -0
- package/dist/editor/tokenizer.d.ts +41 -0
- package/dist/editor/tokenizer.d.ts.map +1 -0
- package/dist/editor/tokenizer.js +513 -0
- package/dist/editor/tokenizer.js.map +1 -0
- package/dist/editor/utils.d.ts +21 -0
- package/dist/editor/utils.d.ts.map +1 -0
- package/dist/editor/utils.js +68 -0
- package/dist/editor/utils.js.map +1 -0
- package/dist/index.d.ts +10 -8
- package/dist/index.js +12 -10
- package/dist/managers/InteractionManager.d.ts +7 -0
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +22 -1
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/ResizeManager.d.ts +10 -2
- package/dist/managers/ResizeManager.d.ts.map +1 -1
- package/dist/managers/ResizeManager.js +33 -13
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/managers/UniversalRenderingManager.d.ts +2 -1
- package/dist/managers/UniversalRenderingManager.d.ts.map +1 -1
- package/dist/managers/UniversalRenderingManager.js +6 -1
- package/dist/managers/UniversalRenderingManager.js.map +1 -1
- package/dist/react/CodeView.d.ts +26 -1
- package/dist/react/CodeView.d.ts.map +1 -1
- package/dist/react/CodeView.js +82 -19
- package/dist/react/CodeView.js.map +1 -1
- package/dist/react/EditContext.d.ts +15 -0
- package/dist/react/EditContext.d.ts.map +1 -0
- package/dist/react/EditContext.js +23 -0
- package/dist/react/EditContext.js.map +1 -0
- package/dist/react/File.d.ts +3 -1
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +4 -2
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +4 -1
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +4 -2
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +7 -5
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +4 -2
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +4 -1
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +4 -2
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +1 -0
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js +2 -1
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +2 -1
- package/dist/react/types.d.ts +3 -0
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +2 -0
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +16 -8
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/renderFileChildren.d.ts +2 -0
- package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
- package/dist/react/utils/renderFileChildren.js +16 -8
- package/dist/react/utils/renderFileChildren.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts +3 -1
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +30 -6
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +4 -1
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +30 -5
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +28 -2
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +244 -22
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +8 -1
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +155 -45
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.d.ts +11 -10
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadDiffs.js +15 -7
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/style.js +1 -1
- package/dist/types.d.ts +282 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/applyLineTextWithNewline.d.ts +5 -0
- package/dist/utils/applyLineTextWithNewline.d.ts.map +1 -0
- package/dist/utils/applyLineTextWithNewline.js +11 -0
- package/dist/utils/applyLineTextWithNewline.js.map +1 -0
- package/dist/utils/areHunkDataEqual.js +1 -1
- package/dist/utils/areHunkDataEqual.js.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.d.ts +2 -2
- package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.js +5 -0
- package/dist/utils/areManagedSnapshotsEqual.js.map +1 -1
- package/dist/utils/awaitWithTimeout.d.ts +5 -0
- package/dist/utils/awaitWithTimeout.d.ts.map +1 -0
- package/dist/utils/awaitWithTimeout.js +15 -0
- package/dist/utils/awaitWithTimeout.js.map +1 -0
- package/dist/utils/cleanLastNewline.js +6 -1
- package/dist/utils/cleanLastNewline.js.map +1 -1
- package/dist/utils/cloneFileDiffMetadata.d.ts +7 -0
- package/dist/utils/cloneFileDiffMetadata.d.ts.map +1 -0
- package/dist/utils/cloneFileDiffMetadata.js +16 -0
- package/dist/utils/cloneFileDiffMetadata.js.map +1 -0
- package/dist/utils/computeEstimatedDiffHeights.d.ts +3 -1
- package/dist/utils/computeEstimatedDiffHeights.d.ts.map +1 -1
- package/dist/utils/computeEstimatedDiffHeights.js +8 -1
- package/dist/utils/computeEstimatedDiffHeights.js.map +1 -1
- package/dist/utils/computeFileOffsets.d.ts +21 -0
- package/dist/utils/computeFileOffsets.d.ts.map +1 -0
- package/dist/utils/computeFileOffsets.js +51 -0
- package/dist/utils/computeFileOffsets.js.map +1 -0
- package/dist/utils/createCodeViewHeaderFooterHostElement.d.ts +5 -0
- package/dist/utils/createCodeViewHeaderFooterHostElement.d.ts.map +1 -0
- package/dist/utils/createCodeViewHeaderFooterHostElement.js +19 -0
- package/dist/utils/createCodeViewHeaderFooterHostElement.js.map +1 -0
- package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
- package/dist/utils/createFileHeaderElement.js +5 -1
- package/dist/utils/createFileHeaderElement.js.map +1 -1
- package/dist/utils/createTransformerWithState.js +9 -0
- package/dist/utils/createTransformerWithState.js.map +1 -1
- package/dist/utils/editSessionHunks.d.ts +84 -0
- package/dist/utils/editSessionHunks.d.ts.map +1 -0
- package/dist/utils/editSessionHunks.js +366 -0
- package/dist/utils/editSessionHunks.js.map +1 -0
- package/dist/utils/getDiffFileInput.d.ts +14 -0
- package/dist/utils/getDiffFileInput.d.ts.map +1 -0
- package/dist/utils/getDiffFileInput.js +24 -0
- package/dist/utils/getDiffFileInput.js.map +1 -0
- package/dist/utils/getDiffHunksRendererOptions.js +1 -0
- package/dist/utils/getDiffHunksRendererOptions.js.map +1 -1
- package/dist/utils/getFiletypeFromFileName.d.ts.map +1 -1
- package/dist/utils/getFiletypeFromFileName.js +2 -0
- package/dist/utils/getFiletypeFromFileName.js.map +1 -1
- package/dist/utils/hydratePartialDiff.d.ts +10 -0
- package/dist/utils/hydratePartialDiff.d.ts.map +1 -0
- package/dist/utils/hydratePartialDiff.js +140 -0
- package/dist/utils/hydratePartialDiff.js.map +1 -0
- package/dist/utils/iterateOverDiff.js +3 -3
- package/dist/utils/iterateOverDiff.js.map +1 -1
- package/dist/utils/parseDiffFromFile.d.ts +1 -1
- package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseDiffFromFile.js +26 -5
- package/dist/utils/parseDiffFromFile.js.map +1 -1
- package/dist/utils/parsePatchFiles.d.ts.map +1 -1
- package/dist/utils/parsePatchFiles.js +2 -0
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/utils/realignChangeContent.d.ts +28 -0
- package/dist/utils/realignChangeContent.d.ts.map +1 -0
- package/dist/utils/realignChangeContent.js +142 -0
- package/dist/utils/realignChangeContent.js.map +1 -0
- package/dist/utils/renderDiffWithHighlighter.js +1 -1
- package/dist/utils/renderFileWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +5 -14
- package/dist/utils/renderFileWithHighlighter.js.map +1 -1
- package/dist/utils/updateDiffHunks.d.ts +24 -0
- package/dist/utils/updateDiffHunks.d.ts.map +1 -0
- package/dist/utils/updateDiffHunks.js +235 -0
- package/dist/utils/updateDiffHunks.js.map +1 -0
- package/dist/utils/virtualDiffLayout.d.ts +40 -1
- package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
- package/dist/utils/virtualDiffLayout.js +96 -1
- package/dist/utils/virtualDiffLayout.js.map +1 -1
- package/dist/worker/WorkerPoolManager.d.ts +7 -2
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +83 -18
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/index.d.ts +2 -2
- package/dist/worker/types.d.ts +11 -1
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/worker-portable.js +46 -66
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +46 -66
- package/dist/worker/worker.js.map +1 -1
- package/package.json +12 -5
- package/dist/utils/iterateOverFile.d.ts +0 -50
- package/dist/utils/iterateOverFile.d.ts.map +0 -1
- package/dist/utils/iterateOverFile.js +0 -49
- package/dist/utils/iterateOverFile.js.map +0 -1
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import "../constants.js";
|
|
2
2
|
import { areObjectsEqual } from "../utils/areObjectsEqual.js";
|
|
3
3
|
import { areOptionsEqual } from "../utils/areOptionsEqual.js";
|
|
4
|
+
import { parseDiffFromFile } from "../utils/parseDiffFromFile.js";
|
|
4
5
|
import { computeVirtualFileMetrics, getVirtualFileHeaderRegion, getVirtualFilePaddingBottom } from "../utils/computeVirtualFileMetrics.js";
|
|
6
|
+
import { getExpandedRegion, getLeadingHunkSeparatorLayout, getTrailingExpandedRegion, getTrailingHunkSeparatorLayout, isAdditionLineRenderable } from "../utils/virtualDiffLayout.js";
|
|
7
|
+
import { areFilesEqual } from "../utils/areFilesEqual.js";
|
|
5
8
|
import { FILE_ANNOTATION_DOM_KEY, includesFileAnnotations, shouldRenderFileAnnotations } from "../utils/includesFileAnnotations.js";
|
|
6
9
|
import { areDiffTargetsEqual } from "../utils/areDiffTargetsEqual.js";
|
|
7
|
-
import {
|
|
10
|
+
import { awaitWithTimeout } from "../utils/awaitWithTimeout.js";
|
|
8
11
|
import { computeEstimatedDiffHeights } from "../utils/computeEstimatedDiffHeights.js";
|
|
12
|
+
import { getDiffFileInput } from "../utils/getDiffFileInput.js";
|
|
13
|
+
import { hydratePartialDiff } from "../utils/hydratePartialDiff.js";
|
|
9
14
|
import { iterateOverDiff } from "../utils/iterateOverDiff.js";
|
|
10
|
-
import { parseDiffFromFile } from "../utils/parseDiffFromFile.js";
|
|
11
15
|
import { FileDiff } from "./FileDiff.js";
|
|
12
16
|
//#region src/components/VirtualizedFileDiff.ts
|
|
13
|
-
const
|
|
17
|
+
const VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL = 3e3;
|
|
14
18
|
let instanceId = -1;
|
|
15
19
|
var VirtualizedFileDiff = class extends FileDiff {
|
|
16
20
|
__id = `little-virtualized-file-diff:${++instanceId}`;
|
|
@@ -32,6 +36,9 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
32
36
|
layoutDirty = true;
|
|
33
37
|
forceRenderOverride;
|
|
34
38
|
currentCollapsed;
|
|
39
|
+
currentExpandUnchanged;
|
|
40
|
+
pendingHydratedDiff;
|
|
41
|
+
pendingExpansions;
|
|
35
42
|
constructor(options, virtualizer, metrics, workerManager, isContainerManaged = false) {
|
|
36
43
|
super(options, workerManager, isContainerManaged);
|
|
37
44
|
this.virtualizer = virtualizer;
|
|
@@ -92,19 +99,23 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
92
99
|
if (this.isAdvancedMode()) throw new Error("VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.");
|
|
93
100
|
super.setThemeType(themeType);
|
|
94
101
|
}
|
|
95
|
-
resetLayoutCache({ forceSimpleRecompute = false, includeEstimatedHeights = false } = {}) {
|
|
102
|
+
resetLayoutCache({ forceSimpleRecompute = false, includeEstimatedHeights = false, resetRenderRange = true } = {}) {
|
|
96
103
|
this.layoutDirty = true;
|
|
97
104
|
this.cache.fileAnnotationHeight = 0;
|
|
98
105
|
if (this.cache.heightDeltas.size > 0) this.cache.heightDeltas.clear();
|
|
99
106
|
if (this.cache.measuredHeightDeltaTotal !== 0) this.cache.measuredHeightDeltaTotal = 0;
|
|
107
|
+
this.invalidateDerivedLayoutCache(includeEstimatedHeights, resetRenderRange);
|
|
108
|
+
if (forceSimpleRecompute && this.isSimpleMode()) this.computeApproximateSize();
|
|
109
|
+
}
|
|
110
|
+
invalidateDerivedLayoutCache(includeEstimatedHeights, resetRenderRange = true) {
|
|
111
|
+
this.layoutDirty = true;
|
|
100
112
|
if (this.cache.checkpoints.length > 0) this.cache.checkpoints.length = 0;
|
|
101
113
|
if (this.cache.totalLines !== 0) this.cache.totalLines = 0;
|
|
102
114
|
if (includeEstimatedHeights) {
|
|
103
115
|
this.cache.estimatedSplitHeight = void 0;
|
|
104
116
|
this.cache.estimatedUnifiedHeight = void 0;
|
|
105
117
|
}
|
|
106
|
-
if (this.renderRange != null) this.renderRange = void 0;
|
|
107
|
-
if (forceSimpleRecompute && this.isSimpleMode()) this.computeApproximateSize();
|
|
118
|
+
if (this.renderRange != null && resetRenderRange) this.renderRange = void 0;
|
|
108
119
|
}
|
|
109
120
|
reconcileHeights() {
|
|
110
121
|
let hasHeightChange = false;
|
|
@@ -166,11 +177,16 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
166
177
|
shouldResetLayoutCache = true;
|
|
167
178
|
includeEstimatedHeights = true;
|
|
168
179
|
}
|
|
169
|
-
const { collapsed = false } = this.options;
|
|
180
|
+
const { collapsed = false, expandUnchanged = false } = this.options;
|
|
170
181
|
if (this.currentCollapsed !== collapsed) {
|
|
171
182
|
this.currentCollapsed = collapsed;
|
|
172
183
|
shouldResetLayoutCache = true;
|
|
173
184
|
}
|
|
185
|
+
if (this.currentExpandUnchanged !== expandUnchanged) {
|
|
186
|
+
this.currentExpandUnchanged = expandUnchanged;
|
|
187
|
+
shouldResetLayoutCache = true;
|
|
188
|
+
includeEstimatedHeights = true;
|
|
189
|
+
}
|
|
174
190
|
if (shouldResetLayoutCache) this.resetLayoutCache({ includeEstimatedHeights });
|
|
175
191
|
this.fileDiff = fileDiff;
|
|
176
192
|
this.top = top;
|
|
@@ -252,6 +268,10 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
252
268
|
});
|
|
253
269
|
return position;
|
|
254
270
|
}
|
|
271
|
+
getScrollContainer() {
|
|
272
|
+
const root = this.getSimpleVirtualizer()?.getRoot();
|
|
273
|
+
return root instanceof HTMLElement ? root : root?.documentElement;
|
|
274
|
+
}
|
|
255
275
|
getNumericScrollAnchor(localViewportTop) {
|
|
256
276
|
if (this.fileDiff == null) return;
|
|
257
277
|
const { disableFileHeader = false, expandUnchanged = false, collapsed = false, collapsedContextThreshold = 1 } = this.options;
|
|
@@ -331,17 +351,139 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
331
351
|
}
|
|
332
352
|
cleanUp(recycle = false) {
|
|
333
353
|
if (this.fileContainer != null && this.isSimpleMode()) this.getSimpleVirtualizer()?.disconnect(this.fileContainer);
|
|
334
|
-
if (!recycle)
|
|
354
|
+
if (!recycle) {
|
|
355
|
+
this.resetLayoutCache({ includeEstimatedHeights: true });
|
|
356
|
+
this.pendingExpansions = void 0;
|
|
357
|
+
this.pendingHydratedDiff = void 0;
|
|
358
|
+
}
|
|
335
359
|
this.isSetup = false;
|
|
336
360
|
super.cleanUp(recycle);
|
|
337
361
|
}
|
|
338
362
|
expandHunk = (hunkIndex, direction, expansionLineCountOverride) => {
|
|
339
|
-
this.
|
|
363
|
+
if (this.fileDiff == null) return;
|
|
364
|
+
if (this.isAdvancedMode()) {
|
|
365
|
+
this.pendingExpansions ??= [];
|
|
366
|
+
this.pendingExpansions.push({
|
|
367
|
+
hunkIndex,
|
|
368
|
+
direction,
|
|
369
|
+
expansionLineCountOverride
|
|
370
|
+
});
|
|
371
|
+
} else {
|
|
372
|
+
this.hunksRenderer.expandHunk(hunkIndex, direction, expansionLineCountOverride);
|
|
373
|
+
this.resetLayoutCache({ includeEstimatedHeights: true });
|
|
374
|
+
this.computeApproximateSize();
|
|
375
|
+
}
|
|
376
|
+
this.loadFilesIfNecessary();
|
|
340
377
|
this.forceRenderOverride = true;
|
|
341
|
-
this.resetLayoutCache({ includeEstimatedHeights: true });
|
|
342
|
-
if (this.isSimpleMode()) this.computeApproximateSize();
|
|
343
378
|
this.virtualizer.instanceChanged(this, true);
|
|
344
379
|
};
|
|
380
|
+
async handleFilesLoaded(expectedDiff, files) {
|
|
381
|
+
if (this.fileDiff !== expectedDiff || !expectedDiff.isPartial) return;
|
|
382
|
+
if (this.isAdvancedMode()) {
|
|
383
|
+
const nextDiff = hydratePartialDiff("clone", expectedDiff, files);
|
|
384
|
+
await awaitWithTimeout(() => this.primeHighlightCache(nextDiff));
|
|
385
|
+
if (!this.enabled || this.fileDiff !== expectedDiff) return;
|
|
386
|
+
this.pendingHydratedDiff = {
|
|
387
|
+
expectedDiff,
|
|
388
|
+
nextDiff,
|
|
389
|
+
files
|
|
390
|
+
};
|
|
391
|
+
} else {
|
|
392
|
+
hydratePartialDiff("merge", expectedDiff, files);
|
|
393
|
+
this.setHydratedState(files);
|
|
394
|
+
await awaitWithTimeout(() => this.primeHighlightCache(expectedDiff));
|
|
395
|
+
if (!this.enabled || this.fileDiff !== expectedDiff) return;
|
|
396
|
+
this.resetLayoutCache({ includeEstimatedHeights: true });
|
|
397
|
+
this.computeApproximateSize();
|
|
398
|
+
}
|
|
399
|
+
this.forceRenderOverride = true;
|
|
400
|
+
this.virtualizer.instanceChanged(this, true);
|
|
401
|
+
}
|
|
402
|
+
consumeCodeViewLayoutChanges(expectedFileDiff) {
|
|
403
|
+
let hasLayoutChange = false;
|
|
404
|
+
let nextDiff;
|
|
405
|
+
const { pendingExpansions, pendingHydratedDiff } = this;
|
|
406
|
+
if (pendingExpansions != null) {
|
|
407
|
+
this.pendingExpansions = void 0;
|
|
408
|
+
for (const pendingExpansion of pendingExpansions) {
|
|
409
|
+
this.hunksRenderer.expandHunk(pendingExpansion.hunkIndex, pendingExpansion.direction, pendingExpansion.expansionLineCountOverride);
|
|
410
|
+
hasLayoutChange = true;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
if (pendingHydratedDiff != null) {
|
|
414
|
+
this.pendingHydratedDiff = void 0;
|
|
415
|
+
if (pendingHydratedDiff.expectedDiff === expectedFileDiff) {
|
|
416
|
+
this.setHydratedState(pendingHydratedDiff.files);
|
|
417
|
+
nextDiff = pendingHydratedDiff.nextDiff;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
if (nextDiff != null) {
|
|
421
|
+
this.forceRenderOverride = true;
|
|
422
|
+
this.resetLayoutCache({ includeEstimatedHeights: true });
|
|
423
|
+
} else if (hasLayoutChange) {
|
|
424
|
+
this.forceRenderOverride = true;
|
|
425
|
+
this.invalidateDerivedLayoutCache(true);
|
|
426
|
+
}
|
|
427
|
+
return nextDiff;
|
|
428
|
+
}
|
|
429
|
+
loadFilesIfNecessary() {
|
|
430
|
+
if (this.pendingHydratedDiff != null) {
|
|
431
|
+
if (this.pendingHydratedDiff.expectedDiff === this.fileDiff) return;
|
|
432
|
+
this.pendingHydratedDiff = void 0;
|
|
433
|
+
}
|
|
434
|
+
super.loadFilesIfNecessary();
|
|
435
|
+
}
|
|
436
|
+
isLineRenderable(lineNumber) {
|
|
437
|
+
if (super.isLineRenderable(lineNumber)) return true;
|
|
438
|
+
const { pendingExpansions } = this;
|
|
439
|
+
const fileDiff = this.fileDiffCache;
|
|
440
|
+
if (pendingExpansions == null || pendingExpansions.length === 0 || fileDiff == null) return false;
|
|
441
|
+
const { expansionLineCount = 100, collapsedContextThreshold = 1 } = this.options;
|
|
442
|
+
const staged = new Map(this.hunksRenderer.getExpandedHunksMap());
|
|
443
|
+
for (const expansion of pendingExpansions) {
|
|
444
|
+
const region = { ...staged.get(expansion.hunkIndex) ?? {
|
|
445
|
+
fromStart: 0,
|
|
446
|
+
fromEnd: 0
|
|
447
|
+
} };
|
|
448
|
+
const count = expansion.expansionLineCountOverride ?? expansionLineCount;
|
|
449
|
+
if (expansion.direction === "up" || expansion.direction === "both") region.fromStart += count;
|
|
450
|
+
if (expansion.direction === "down" || expansion.direction === "both") region.fromEnd += count;
|
|
451
|
+
staged.set(expansion.hunkIndex, region);
|
|
452
|
+
}
|
|
453
|
+
return isAdditionLineRenderable({
|
|
454
|
+
fileDiff,
|
|
455
|
+
lineNumber,
|
|
456
|
+
expandedHunks: staged,
|
|
457
|
+
collapsedContextThreshold
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Invalidate layout after an edit session changed the rendered row set
|
|
462
|
+
* without a line-count change (a mid-session region change or the exit
|
|
463
|
+
* recompute): estimated heights bake the hunk shapes in, and nothing else
|
|
464
|
+
* invalidates them now that editing does not flip expandUnchanged. Public
|
|
465
|
+
* so CodeView can run it when reaping a session whose instance was already
|
|
466
|
+
* released.
|
|
467
|
+
*/
|
|
468
|
+
invalidateEditSessionLayout() {
|
|
469
|
+
this.getSimpleVirtualizer()?.markDOMDirty();
|
|
470
|
+
this.resetLayoutCache({
|
|
471
|
+
forceSimpleRecompute: this.isSimpleMode(),
|
|
472
|
+
includeEstimatedHeights: true,
|
|
473
|
+
resetRenderRange: false
|
|
474
|
+
});
|
|
475
|
+
if (!this.isSimpleMode()) this.computeApproximateSize(true);
|
|
476
|
+
this.getSimpleVirtualizer()?.requestHeightReconcile(this);
|
|
477
|
+
}
|
|
478
|
+
escalateEditSessionRender() {
|
|
479
|
+
this.invalidateEditSessionLayout();
|
|
480
|
+
if (!this.enabled || this.fileDiff == null) return;
|
|
481
|
+
this.forceRenderOverride = true;
|
|
482
|
+
this.virtualizer.instanceChanged(this, true);
|
|
483
|
+
}
|
|
484
|
+
shouldSelfHealEditSession() {
|
|
485
|
+
return !this.isAdvancedMode() && super.shouldSelfHealEditSession();
|
|
486
|
+
}
|
|
345
487
|
setVisibility(visible) {
|
|
346
488
|
if (this.isAdvancedMode() || this.fileContainer == null) return;
|
|
347
489
|
this.renderRange = void 0;
|
|
@@ -358,14 +500,30 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
358
500
|
this.forceRenderOverride = true;
|
|
359
501
|
this.virtualizer.instanceChanged(this, false);
|
|
360
502
|
}
|
|
361
|
-
|
|
503
|
+
applyDocumentChange(textDocument, newLineAnnotations, shouldUpdateBuffer = false) {
|
|
504
|
+
const previousRenderRange = this.renderRange;
|
|
505
|
+
super.applyDocumentChange(textDocument, newLineAnnotations);
|
|
506
|
+
this.getSimpleVirtualizer()?.markDOMDirty();
|
|
507
|
+
this.resetLayoutCache({
|
|
508
|
+
forceSimpleRecompute: this.isSimpleMode(),
|
|
509
|
+
includeEstimatedHeights: true,
|
|
510
|
+
resetRenderRange: false
|
|
511
|
+
});
|
|
512
|
+
if (!this.isSimpleMode()) this.computeApproximateSize(true);
|
|
513
|
+
if (shouldUpdateBuffer && previousRenderRange !== void 0 && this.fileDiff !== void 0) {
|
|
514
|
+
const windowSpecs = this.virtualizer.getWindowSpecs();
|
|
515
|
+
const renderRange = this.computeRenderRangeFromWindow(this.fileDiff, this.top ?? 0, windowSpecs);
|
|
516
|
+
if (renderRange.bufferAfter !== previousRenderRange.bufferAfter) this.updateBuffers(renderRange);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
computeApproximateSize(force = false, fileDiff = this.fileDiff) {
|
|
362
520
|
const shouldValidateSize = this.isResizeDebuggingEnabled();
|
|
363
521
|
if (!force && !this.layoutDirty && !shouldValidateSize) return;
|
|
364
522
|
const isFirstCompute = this.height === 0;
|
|
365
523
|
this.height = 0;
|
|
366
524
|
this.cache.checkpoints = [];
|
|
367
525
|
this.cache.totalLines = 0;
|
|
368
|
-
if (
|
|
526
|
+
if (fileDiff == null) {
|
|
369
527
|
this.layoutDirty = false;
|
|
370
528
|
return;
|
|
371
529
|
}
|
|
@@ -376,18 +534,18 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
376
534
|
this.layoutDirty = false;
|
|
377
535
|
return;
|
|
378
536
|
}
|
|
379
|
-
this.height = this.getActiveEstimatedHeight() + this.cache.measuredHeightDeltaTotal;
|
|
380
|
-
if (shouldValidateSize && !isFirstCompute) this.validateComputedHeight();
|
|
537
|
+
this.height = this.getActiveEstimatedHeight(fileDiff) + this.cache.measuredHeightDeltaTotal;
|
|
538
|
+
if (shouldValidateSize && !isFirstCompute) this.validateComputedHeight(fileDiff);
|
|
381
539
|
this.layoutDirty = false;
|
|
382
540
|
}
|
|
383
|
-
getActiveEstimatedHeight() {
|
|
384
|
-
this.ensureEstimatedDiffHeights();
|
|
541
|
+
getActiveEstimatedHeight(fileDiff = this.fileDiff) {
|
|
542
|
+
this.ensureEstimatedDiffHeights(fileDiff);
|
|
385
543
|
const estimatedHeight = this.getDiffStyle() === "split" ? this.cache.estimatedSplitHeight : this.cache.estimatedUnifiedHeight;
|
|
386
544
|
if (estimatedHeight == null) throw new Error("VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height");
|
|
387
545
|
return estimatedHeight;
|
|
388
546
|
}
|
|
389
|
-
ensureEstimatedDiffHeights() {
|
|
390
|
-
if (
|
|
547
|
+
ensureEstimatedDiffHeights(fileDiff = this.fileDiff) {
|
|
548
|
+
if (fileDiff == null) {
|
|
391
549
|
this.cache.estimatedSplitHeight = void 0;
|
|
392
550
|
this.cache.estimatedUnifiedHeight = void 0;
|
|
393
551
|
return;
|
|
@@ -395,40 +553,51 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
395
553
|
if (this.cache.estimatedSplitHeight != null && this.cache.estimatedUnifiedHeight != null) return;
|
|
396
554
|
const { disableFileHeader = false, expandUnchanged = false, collapsedContextThreshold = 1 } = this.options;
|
|
397
555
|
const { splitHeight, unifiedHeight } = computeEstimatedDiffHeights({
|
|
398
|
-
fileDiff
|
|
556
|
+
fileDiff,
|
|
399
557
|
metrics: this.metrics,
|
|
400
558
|
disableFileHeader,
|
|
401
559
|
hunkSeparators: this.getHunkSeparatorType(),
|
|
402
560
|
expandUnchanged,
|
|
403
561
|
expandedHunks: this.hunksRenderer.getExpandedHunksMap(),
|
|
404
|
-
collapsedContextThreshold
|
|
562
|
+
collapsedContextThreshold,
|
|
563
|
+
canHydratePartialDiff: canHydrateCollapsedContext(fileDiff, this.options.loadDiffFiles != null)
|
|
405
564
|
});
|
|
406
565
|
this.cache.estimatedSplitHeight = splitHeight;
|
|
407
566
|
this.cache.estimatedUnifiedHeight = unifiedHeight;
|
|
408
567
|
}
|
|
409
|
-
validateComputedHeight() {
|
|
410
|
-
if (this.fileContainer == null ||
|
|
568
|
+
validateComputedHeight(fileDiff = this.fileDiff) {
|
|
569
|
+
if (this.fileContainer == null || fileDiff == null) return;
|
|
411
570
|
const rect = this.fileContainer.getBoundingClientRect();
|
|
412
571
|
if (rect.height !== this.height) console.log("VirtualizedFileDiff.computeApproximateSize: computed height doesnt match", {
|
|
413
|
-
name:
|
|
572
|
+
name: fileDiff.name,
|
|
414
573
|
elementHeight: rect.height,
|
|
415
574
|
computedHeight: this.height
|
|
416
575
|
});
|
|
417
576
|
else console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT");
|
|
418
577
|
}
|
|
419
|
-
render({ fileContainer,
|
|
578
|
+
render({ fileContainer, fileDiff, forceRender = false, lineAnnotations, ...fileInputProps } = {}) {
|
|
579
|
+
const fileInput = getDiffFileInput(fileInputProps, "VirtualizedFileDiff.render");
|
|
580
|
+
const hasFileInput = fileInput != null;
|
|
581
|
+
const oldFile = fileInput?.oldFile;
|
|
582
|
+
const newFile = fileInput?.newFile;
|
|
583
|
+
const filesDidChange = hasFileInput && (!areOptionalFilesEqual(oldFile, this.deletionFile) || !areOptionalFilesEqual(newFile, this.additionFile));
|
|
584
|
+
let nextFileDiff = fileDiff ?? this.fileDiff;
|
|
585
|
+
if (fileDiff == null && hasFileInput && (filesDidChange || this.fileDiff == null)) nextFileDiff = parseDiffFromFile(fileInput.oldFile, fileInput.newFile, this.options.parseDiffOptions);
|
|
420
586
|
const { forceRenderOverride, isSetup } = this;
|
|
421
587
|
this.forceRenderOverride = void 0;
|
|
422
588
|
const annotationsChanged = this.syncLineAnnotations(lineAnnotations);
|
|
423
589
|
if (annotationsChanged) this.resetLayoutCache({ includeEstimatedHeights: false });
|
|
424
|
-
|
|
590
|
+
const diffInputChanged = fileDiff != null && fileDiff !== this.fileDiff;
|
|
591
|
+
const targetChanged = nextFileDiff != null && !areDiffTargetsEqual(this.fileDiff, nextFileDiff);
|
|
592
|
+
const dataChanged = diffInputChanged || filesDidChange;
|
|
593
|
+
if (targetChanged) this.resetLayoutCache({ includeEstimatedHeights: true });
|
|
425
594
|
fileContainer = this.getOrCreateFileContainer(fileContainer);
|
|
426
|
-
if (
|
|
595
|
+
if (nextFileDiff == null) {
|
|
427
596
|
console.error("VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data");
|
|
428
597
|
return false;
|
|
429
598
|
}
|
|
430
599
|
if (!isSetup) {
|
|
431
|
-
this.computeApproximateSize();
|
|
600
|
+
this.computeApproximateSize(false, nextFileDiff);
|
|
432
601
|
const virtualizer = this.getSimpleVirtualizer();
|
|
433
602
|
this.top ??= this.getVirtualizedTop();
|
|
434
603
|
if (this.isAdvancedMode()) this.isVisible = true;
|
|
@@ -438,21 +607,33 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
438
607
|
this.isVisible = virtualizer.isInstanceVisible(this.top ?? 0, this.height);
|
|
439
608
|
}
|
|
440
609
|
this.isSetup = true;
|
|
441
|
-
} else
|
|
442
|
-
|
|
610
|
+
} else {
|
|
611
|
+
this.top ??= this.getVirtualizedTop();
|
|
612
|
+
if (targetChanged) this.computeApproximateSize(false, nextFileDiff);
|
|
613
|
+
}
|
|
614
|
+
if (!this.isVisible && this.isSimpleMode() && (!dataChanged || !isSetup)) {
|
|
615
|
+
this.fileDiff = nextFileDiff;
|
|
616
|
+
if (fileInput != null) {
|
|
617
|
+
this.deletionFile = oldFile;
|
|
618
|
+
this.additionFile = newFile;
|
|
619
|
+
}
|
|
620
|
+
if (targetChanged) this.cachedHeaderHTML = void 0;
|
|
621
|
+
return this.renderPlaceholder(this.height);
|
|
622
|
+
}
|
|
443
623
|
const windowSpecs = this.virtualizer.getWindowSpecs();
|
|
444
624
|
const fileTop = this.top ?? 0;
|
|
445
|
-
const renderRange = this.computeRenderRangeFromWindow(
|
|
446
|
-
|
|
447
|
-
fileDiff:
|
|
625
|
+
const renderRange = this.computeRenderRangeFromWindow(nextFileDiff, fileTop, windowSpecs);
|
|
626
|
+
const rendered = super.render({
|
|
627
|
+
fileDiff: nextFileDiff,
|
|
448
628
|
fileContainer,
|
|
449
629
|
renderRange,
|
|
450
|
-
oldFile,
|
|
451
|
-
newFile,
|
|
452
630
|
lineAnnotations,
|
|
453
|
-
forceRender: (forceRenderOverride ?? forceRender) || annotationsChanged,
|
|
454
|
-
...
|
|
631
|
+
forceRender: (forceRenderOverride ?? forceRender) || annotationsChanged || targetChanged,
|
|
632
|
+
...fileInput,
|
|
633
|
+
...fileInputProps
|
|
455
634
|
});
|
|
635
|
+
if (this.isSimpleMode() && rendered) this.getSimpleVirtualizer()?.requestHeightReconcile(this);
|
|
636
|
+
return rendered;
|
|
456
637
|
}
|
|
457
638
|
syncVirtualizedTop() {
|
|
458
639
|
this.top = this.getVirtualizedTop();
|
|
@@ -482,10 +663,11 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
482
663
|
getHunkSeparatorType() {
|
|
483
664
|
return getOptionHunkSeparatorType(this.options.hunkSeparators);
|
|
484
665
|
}
|
|
485
|
-
approximateLayoutCheckpoints() {
|
|
486
|
-
if (this.cache.checkpoints.length > 0 ||
|
|
666
|
+
approximateLayoutCheckpoints(fileDiff = this.fileDiff) {
|
|
667
|
+
if (!this.layoutDirty && this.cache.checkpoints.length > 0 || fileDiff == null || fileDiff.hunks.length === 0 || this.options.collapsed === true) return;
|
|
487
668
|
const { disableFileHeader = false, expandUnchanged = false, collapsedContextThreshold = 1 } = this.options;
|
|
488
|
-
const finalHunkIndex =
|
|
669
|
+
const finalHunkIndex = fileDiff.hunks.length - 1;
|
|
670
|
+
const canHydratePartialDiff = canHydrateCollapsedContext(fileDiff, this.options.loadDiffFiles != null);
|
|
489
671
|
const diffStyle = this.getDiffStyle();
|
|
490
672
|
const hunkSeparators = this.getHunkSeparatorType();
|
|
491
673
|
const expandedHunks = expandUnchanged ? true : this.hunksRenderer.getExpandedHunksMap();
|
|
@@ -505,16 +687,16 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
505
687
|
lineIndex: startLineIndex + offset,
|
|
506
688
|
top: checkpointTop
|
|
507
689
|
});
|
|
508
|
-
nextCheckpoint +=
|
|
690
|
+
nextCheckpoint += VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL;
|
|
509
691
|
}
|
|
510
692
|
top += preSeparatorHeight + rowCount * this.metrics.lineHeight + metadataOffsets.length * this.metrics.lineHeight + sumHeightDeltas(heightDeltaPrefix, startLineIndex, startLineIndex + rowCount) + postSeparatorHeight;
|
|
511
693
|
renderedLineIndex = blockEnd;
|
|
512
694
|
};
|
|
513
|
-
for (let hunkIndex = 0; hunkIndex <
|
|
514
|
-
const hunk =
|
|
695
|
+
for (let hunkIndex = 0; hunkIndex < fileDiff.hunks.length; hunkIndex++) {
|
|
696
|
+
const hunk = fileDiff.hunks[hunkIndex];
|
|
515
697
|
if (hunk == null) throw new Error("VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index");
|
|
516
698
|
const leadingRegion = getExpandedRegion({
|
|
517
|
-
isPartial:
|
|
699
|
+
isPartial: fileDiff.isPartial,
|
|
518
700
|
rangeSize: hunk.collapsedBefore,
|
|
519
701
|
expandedHunks,
|
|
520
702
|
hunkIndex,
|
|
@@ -538,7 +720,7 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
538
720
|
});
|
|
539
721
|
if (leadingRegion.fromEnd > 0) pendingLeadingSeparatorHeight = 0;
|
|
540
722
|
const trailingRegion = hunkIndex === finalHunkIndex ? getTrailingExpandedRegion({
|
|
541
|
-
fileDiff
|
|
723
|
+
fileDiff,
|
|
542
724
|
hunkIndex,
|
|
543
725
|
expandedHunks,
|
|
544
726
|
collapsedContextThreshold,
|
|
@@ -547,6 +729,9 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
547
729
|
const trailingSeparatorHeight = trailingRegion != null && trailingRegion.collapsedLines > 0 ? getTrailingHunkSeparatorLayout({
|
|
548
730
|
type: hunkSeparators,
|
|
549
731
|
metrics: this.metrics
|
|
732
|
+
})?.totalHeight ?? 0 : hunkIndex === finalHunkIndex && canHydratePartialDiff ? getTrailingHunkSeparatorLayout({
|
|
733
|
+
type: hunkSeparators,
|
|
734
|
+
metrics: this.metrics
|
|
550
735
|
})?.totalHeight ?? 0 : 0;
|
|
551
736
|
const trailingExpandedCount = trailingRegion != null ? trailingRegion.fromStart + trailingRegion.fromEnd : 0;
|
|
552
737
|
const hunkBodyRowCount = diffStyle === "split" ? hunk.splitLineCount : hunk.unifiedLineCount;
|
|
@@ -637,13 +822,19 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
637
822
|
if (trailingRegion != null) count += trailingRegion.fromStart + trailingRegion.fromEnd;
|
|
638
823
|
return count;
|
|
639
824
|
}
|
|
825
|
+
getLayoutLineCount(fileDiff, diffStyle) {
|
|
826
|
+
const expandedLineCount = this.getExpandedLineCount(fileDiff, diffStyle);
|
|
827
|
+
const metadataLineCount = diffStyle === "split" ? fileDiff.splitLineCount : fileDiff.unifiedLineCount;
|
|
828
|
+
return Math.max(expandedLineCount, metadataLineCount, fileDiff.additionLines.length, fileDiff.deletionLines.length, this.cache.totalLines);
|
|
829
|
+
}
|
|
640
830
|
computeRenderRangeFromWindow(fileDiff, fileTop, { top, bottom }) {
|
|
641
831
|
const { disableFileHeader = false, expandUnchanged = false, collapsedContextThreshold = 1 } = this.options;
|
|
642
832
|
const { hunkLineCount, lineHeight } = this.metrics;
|
|
643
833
|
const diffStyle = this.getDiffStyle();
|
|
644
834
|
const hunkSeparators = this.getHunkSeparatorType();
|
|
835
|
+
const canHydratePartialDiff = canHydrateCollapsedContext(fileDiff, this.options.loadDiffFiles != null);
|
|
645
836
|
const fileHeight = this.height;
|
|
646
|
-
let lineCount = this.
|
|
837
|
+
let lineCount = this.getLayoutLineCount(fileDiff, diffStyle);
|
|
647
838
|
const headerRegion = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
|
|
648
839
|
const paddingBottom = fileDiff.hunks.length > 0 ? getVirtualFilePaddingBottom(this.metrics) : 0;
|
|
649
840
|
const { fileAnnotationHeight } = this.cache;
|
|
@@ -664,8 +855,8 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
664
855
|
bufferBefore: 0,
|
|
665
856
|
bufferAfter: 0
|
|
666
857
|
};
|
|
667
|
-
this.approximateLayoutCheckpoints();
|
|
668
|
-
lineCount = this.
|
|
858
|
+
this.approximateLayoutCheckpoints(fileDiff);
|
|
859
|
+
lineCount = this.getLayoutLineCount(fileDiff, diffStyle);
|
|
669
860
|
const estimatedTargetLines = Math.ceil(Math.max(bottom - top, 0) / lineHeight);
|
|
670
861
|
const totalLines = Math.ceil(estimatedTargetLines / hunkLineCount) * hunkLineCount + hunkLineCount;
|
|
671
862
|
const totalHunks = totalLines / hunkLineCount;
|
|
@@ -688,6 +879,7 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
688
879
|
const splitLineIndex = additionLine != null ? additionLine.splitLineIndex : deletionLine.splitLineIndex;
|
|
689
880
|
const unifiedLineIndex = additionLine != null ? additionLine.unifiedLineIndex : deletionLine.unifiedLineIndex;
|
|
690
881
|
const hasMetadata = (additionLine?.noEOFCR ?? false) || (deletionLine?.noEOFCR ?? false);
|
|
882
|
+
const isFinalHunkRow = hunkIndex === fileDiff.hunks.length - 1 && hunk != null && (diffStyle === "split" ? splitLineIndex === hunk.splitLineStart + hunk.splitLineCount - 1 : unifiedLineIndex === hunk.unifiedLineStart + hunk.unifiedLineCount - 1);
|
|
691
883
|
const gapAdjustment = (collapsedBefore > 0 ? getLeadingHunkSeparatorLayout({
|
|
692
884
|
type: hunkSeparators,
|
|
693
885
|
metrics: this.metrics,
|
|
@@ -710,10 +902,17 @@ var VirtualizedFileDiff = class extends FileDiff {
|
|
|
710
902
|
if (overflowCounter == null && absoluteLineTop >= bottom && isAtHunkBoundary) overflowCounter = overflowHunks;
|
|
711
903
|
currentLine++;
|
|
712
904
|
absoluteLineTop += lineHeight;
|
|
713
|
-
if (collapsedAfter > 0
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
905
|
+
if (collapsedAfter > 0 || isFinalHunkRow && canHydratePartialDiff) {
|
|
906
|
+
const trailingSeparator = getTrailingHunkSeparatorLayout({
|
|
907
|
+
type: hunkSeparators,
|
|
908
|
+
metrics: this.metrics
|
|
909
|
+
});
|
|
910
|
+
if (trailingSeparator != null) {
|
|
911
|
+
if (absoluteLineTop < bottom && absoluteLineTop + trailingSeparator.totalHeight > top) firstVisibleHunk ??= currentHunk;
|
|
912
|
+
if (centerHunk == null && absoluteLineTop + trailingSeparator.totalHeight > viewportCenter) centerHunk = currentHunk;
|
|
913
|
+
absoluteLineTop += trailingSeparator.totalHeight;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
717
916
|
return false;
|
|
718
917
|
}
|
|
719
918
|
});
|
|
@@ -791,7 +990,7 @@ function lowerBound(values, target) {
|
|
|
791
990
|
return low;
|
|
792
991
|
}
|
|
793
992
|
function getNextCheckpointIndex(renderedLineIndex) {
|
|
794
|
-
return Math.ceil(renderedLineIndex /
|
|
993
|
+
return Math.ceil(renderedLineIndex / VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL) * VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL;
|
|
795
994
|
}
|
|
796
995
|
function countMetadataOffsetsBefore(metadataOffsets, offset) {
|
|
797
996
|
let count = 0;
|
|
@@ -813,19 +1012,26 @@ function getHunkMetadataOffsets({ diffStyle, hunk, rowCount }) {
|
|
|
813
1012
|
return offsets;
|
|
814
1013
|
}
|
|
815
1014
|
function hasDiffLayoutOptionChanged(previousOptions, nextOptions) {
|
|
816
|
-
return (previousOptions.diffStyle ?? "split") !== (nextOptions.diffStyle ?? "split") || (previousOptions.overflow ?? "scroll") !== (nextOptions.overflow ?? "scroll") || (previousOptions.collapsed ?? false) !== (nextOptions.collapsed ?? false) || (previousOptions.disableLineNumbers ?? false) !== (nextOptions.disableLineNumbers ?? false) || (previousOptions.disableFileHeader ?? false) !== (nextOptions.disableFileHeader ?? false) || (previousOptions.diffIndicators ?? "bars") !== (nextOptions.diffIndicators ?? "bars") || (previousOptions.hunkSeparators ?? "line-info") !== (nextOptions.hunkSeparators ?? "line-info") || (previousOptions.expandUnchanged ?? false) !== (nextOptions.expandUnchanged ?? false) || (previousOptions.collapsedContextThreshold ?? 1) !== (nextOptions.collapsedContextThreshold ?? 1) || previousOptions.unsafeCSS !== nextOptions.unsafeCSS;
|
|
1015
|
+
return (previousOptions.diffStyle ?? "split") !== (nextOptions.diffStyle ?? "split") || (previousOptions.overflow ?? "scroll") !== (nextOptions.overflow ?? "scroll") || (previousOptions.collapsed ?? false) !== (nextOptions.collapsed ?? false) || (previousOptions.disableLineNumbers ?? false) !== (nextOptions.disableLineNumbers ?? false) || (previousOptions.disableFileHeader ?? false) !== (nextOptions.disableFileHeader ?? false) || (previousOptions.diffIndicators ?? "bars") !== (nextOptions.diffIndicators ?? "bars") || (previousOptions.hunkSeparators ?? "line-info") !== (nextOptions.hunkSeparators ?? "line-info") || Boolean(previousOptions.loadDiffFiles) !== Boolean(nextOptions.loadDiffFiles) || (previousOptions.expandUnchanged ?? false) !== (nextOptions.expandUnchanged ?? false) || (previousOptions.collapsedContextThreshold ?? 1) !== (nextOptions.collapsedContextThreshold ?? 1) || previousOptions.unsafeCSS !== nextOptions.unsafeCSS;
|
|
817
1016
|
}
|
|
818
1017
|
function hasDiffEstimateOptionChanged(previousOptions, nextOptions) {
|
|
819
|
-
return (previousOptions.disableFileHeader ?? false) !== (nextOptions.disableFileHeader ?? false) || (previousOptions.hunkSeparators ?? "line-info") !== (nextOptions.hunkSeparators ?? "line-info") || (previousOptions.expandUnchanged ?? false) !== (nextOptions.expandUnchanged ?? false) || (previousOptions.collapsedContextThreshold ?? 1) !== (nextOptions.collapsedContextThreshold ?? 1);
|
|
1018
|
+
return (previousOptions.disableFileHeader ?? false) !== (nextOptions.disableFileHeader ?? false) || (previousOptions.hunkSeparators ?? "line-info") !== (nextOptions.hunkSeparators ?? "line-info") || Boolean(previousOptions.loadDiffFiles) !== Boolean(nextOptions.loadDiffFiles) || (previousOptions.expandUnchanged ?? false) !== (nextOptions.expandUnchanged ?? false) || (previousOptions.collapsedContextThreshold ?? 1) !== (nextOptions.collapsedContextThreshold ?? 1);
|
|
1019
|
+
}
|
|
1020
|
+
function canHydrateCollapsedContext(fileDiff, hasFileLoader) {
|
|
1021
|
+
return fileDiff.isPartial && hasFileLoader && (fileDiff.type === "change" || fileDiff.type === "rename-changed");
|
|
820
1022
|
}
|
|
821
1023
|
function getOptionHunkSeparatorType(hunkSeparators) {
|
|
822
1024
|
return typeof hunkSeparators === "function" ? "custom" : hunkSeparators ?? "line-info";
|
|
823
1025
|
}
|
|
1026
|
+
function areOptionalFilesEqual(fileA, fileB) {
|
|
1027
|
+
if (fileA == null || fileB == null) return fileA == null && fileB == null;
|
|
1028
|
+
return areFilesEqual(fileA, fileB);
|
|
1029
|
+
}
|
|
824
1030
|
function parseLineIndex(lineIndexAttr, diffStyle) {
|
|
825
1031
|
const [unifiedIndex, splitIndex] = lineIndexAttr.split(",").map(Number);
|
|
826
1032
|
return diffStyle === "split" ? splitIndex : unifiedIndex;
|
|
827
1033
|
}
|
|
828
1034
|
//#endregion
|
|
829
|
-
export { VirtualizedFileDiff };
|
|
1035
|
+
export { VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL, VirtualizedFileDiff };
|
|
830
1036
|
|
|
831
1037
|
//# sourceMappingURL=VirtualizedFileDiff.js.map
|