@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.
Files changed (288) hide show
  1. package/dist/components/CodeView.d.ts +91 -6
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +300 -38
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts +14 -3
  6. package/dist/components/File.d.ts.map +1 -1
  7. package/dist/components/File.js +98 -12
  8. package/dist/components/File.js.map +1 -1
  9. package/dist/components/FileDiff.d.ts +68 -19
  10. package/dist/components/FileDiff.d.ts.map +1 -1
  11. package/dist/components/FileDiff.js +363 -25
  12. package/dist/components/FileDiff.js.map +1 -1
  13. package/dist/components/FileStream.d.ts.map +1 -1
  14. package/dist/components/FileStream.js +2 -1
  15. package/dist/components/FileStream.js.map +1 -1
  16. package/dist/components/UnresolvedFile.d.ts +2 -2
  17. package/dist/components/UnresolvedFile.d.ts.map +1 -1
  18. package/dist/components/UnresolvedFile.js +2 -2
  19. package/dist/components/UnresolvedFile.js.map +1 -1
  20. package/dist/components/VirtualizedFile.d.ts +4 -2
  21. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  22. package/dist/components/VirtualizedFile.js +59 -47
  23. package/dist/components/VirtualizedFile.js.map +1 -1
  24. package/dist/components/VirtualizedFileDiff.d.ts +27 -5
  25. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  26. package/dist/components/VirtualizedFileDiff.js +262 -56
  27. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  28. package/dist/components/Virtualizer.d.ts +4 -1
  29. package/dist/components/Virtualizer.d.ts.map +1 -1
  30. package/dist/components/Virtualizer.js +21 -4
  31. package/dist/components/Virtualizer.js.map +1 -1
  32. package/dist/constants.d.ts +4 -1
  33. package/dist/constants.d.ts.map +1 -1
  34. package/dist/constants.js +4 -1
  35. package/dist/constants.js.map +1 -1
  36. package/dist/editor/command.d.ts +7 -0
  37. package/dist/editor/command.d.ts.map +1 -0
  38. package/dist/editor/command.js +54 -0
  39. package/dist/editor/command.js.map +1 -0
  40. package/dist/editor/editStack.d.ts +71 -0
  41. package/dist/editor/editStack.d.ts.map +1 -0
  42. package/dist/editor/editStack.js +218 -0
  43. package/dist/editor/editStack.js.map +1 -0
  44. package/dist/editor/editor.d.ts +105 -0
  45. package/dist/editor/editor.d.ts.map +1 -0
  46. package/dist/editor/editor.js +2545 -0
  47. package/dist/editor/editor.js.map +1 -0
  48. package/dist/editor/editor2.js +6 -0
  49. package/dist/editor/editor2.js.map +1 -0
  50. package/dist/editor/index.d.ts +5 -0
  51. package/dist/editor/index.js +3 -0
  52. package/dist/editor/languages.d.ts +26 -0
  53. package/dist/editor/languages.d.ts.map +1 -0
  54. package/dist/editor/languages.js +363 -0
  55. package/dist/editor/languages.js.map +1 -0
  56. package/dist/editor/lineAnnotations.d.ts +9 -0
  57. package/dist/editor/lineAnnotations.d.ts.map +1 -0
  58. package/dist/editor/lineAnnotations.js +212 -0
  59. package/dist/editor/lineAnnotations.js.map +1 -0
  60. package/dist/editor/marker.d.ts +38 -0
  61. package/dist/editor/marker.d.ts.map +1 -0
  62. package/dist/editor/marker.js +245 -0
  63. package/dist/editor/marker.js.map +1 -0
  64. package/dist/editor/matchBrackets.d.ts +9 -0
  65. package/dist/editor/matchBrackets.d.ts.map +1 -0
  66. package/dist/editor/matchBrackets.js +138 -0
  67. package/dist/editor/matchBrackets.js.map +1 -0
  68. package/dist/editor/pieceTable.d.ts +41 -0
  69. package/dist/editor/pieceTable.d.ts.map +1 -0
  70. package/dist/editor/pieceTable.js +671 -0
  71. package/dist/editor/pieceTable.js.map +1 -0
  72. package/dist/editor/platform.d.ts +19 -0
  73. package/dist/editor/platform.d.ts.map +1 -0
  74. package/dist/editor/platform.js +57 -0
  75. package/dist/editor/platform.js.map +1 -0
  76. package/dist/editor/popover.d.ts +65 -0
  77. package/dist/editor/popover.d.ts.map +1 -0
  78. package/dist/editor/popover.js +187 -0
  79. package/dist/editor/popover.js.map +1 -0
  80. package/dist/editor/searchPanel.d.ts +40 -0
  81. package/dist/editor/searchPanel.d.ts.map +1 -0
  82. package/dist/editor/searchPanel.js +318 -0
  83. package/dist/editor/searchPanel.js.map +1 -0
  84. package/dist/editor/selection.d.ts +211 -0
  85. package/dist/editor/selection.d.ts.map +1 -0
  86. package/dist/editor/selection.js +1626 -0
  87. package/dist/editor/selection.js.map +1 -0
  88. package/dist/editor/selectionAction.d.ts +46 -0
  89. package/dist/editor/selectionAction.d.ts.map +1 -0
  90. package/dist/editor/selectionAction.js +64 -0
  91. package/dist/editor/selectionAction.js.map +1 -0
  92. package/dist/editor/sprite.d.ts +8 -0
  93. package/dist/editor/sprite.d.ts.map +1 -0
  94. package/dist/editor/sprite.js +45 -0
  95. package/dist/editor/sprite.js.map +1 -0
  96. package/dist/editor/stateStorage.d.ts +15 -0
  97. package/dist/editor/stateStorage.d.ts.map +1 -0
  98. package/dist/editor/stateStorage.js +65 -0
  99. package/dist/editor/stateStorage.js.map +1 -0
  100. package/dist/editor/textDocument.d.ts +77 -0
  101. package/dist/editor/textDocument.d.ts.map +1 -0
  102. package/dist/editor/textDocument.js +271 -0
  103. package/dist/editor/textDocument.js.map +1 -0
  104. package/dist/editor/textMeasure.d.ts +61 -0
  105. package/dist/editor/textMeasure.d.ts.map +1 -0
  106. package/dist/editor/textMeasure.js +209 -0
  107. package/dist/editor/textMeasure.js.map +1 -0
  108. package/dist/editor/tokenizer.d.ts +41 -0
  109. package/dist/editor/tokenizer.d.ts.map +1 -0
  110. package/dist/editor/tokenizer.js +513 -0
  111. package/dist/editor/tokenizer.js.map +1 -0
  112. package/dist/editor/utils.d.ts +21 -0
  113. package/dist/editor/utils.d.ts.map +1 -0
  114. package/dist/editor/utils.js +68 -0
  115. package/dist/editor/utils.js.map +1 -0
  116. package/dist/index.d.ts +10 -8
  117. package/dist/index.js +12 -10
  118. package/dist/managers/InteractionManager.d.ts +7 -0
  119. package/dist/managers/InteractionManager.d.ts.map +1 -1
  120. package/dist/managers/InteractionManager.js +22 -1
  121. package/dist/managers/InteractionManager.js.map +1 -1
  122. package/dist/managers/ResizeManager.d.ts +10 -2
  123. package/dist/managers/ResizeManager.d.ts.map +1 -1
  124. package/dist/managers/ResizeManager.js +33 -13
  125. package/dist/managers/ResizeManager.js.map +1 -1
  126. package/dist/managers/UniversalRenderingManager.d.ts +2 -1
  127. package/dist/managers/UniversalRenderingManager.d.ts.map +1 -1
  128. package/dist/managers/UniversalRenderingManager.js +6 -1
  129. package/dist/managers/UniversalRenderingManager.js.map +1 -1
  130. package/dist/react/CodeView.d.ts +26 -1
  131. package/dist/react/CodeView.d.ts.map +1 -1
  132. package/dist/react/CodeView.js +82 -19
  133. package/dist/react/CodeView.js.map +1 -1
  134. package/dist/react/EditContext.d.ts +15 -0
  135. package/dist/react/EditContext.d.ts.map +1 -0
  136. package/dist/react/EditContext.js +23 -0
  137. package/dist/react/EditContext.js.map +1 -0
  138. package/dist/react/File.d.ts +3 -1
  139. package/dist/react/File.d.ts.map +1 -1
  140. package/dist/react/File.js +4 -2
  141. package/dist/react/File.js.map +1 -1
  142. package/dist/react/FileDiff.d.ts +4 -1
  143. package/dist/react/FileDiff.d.ts.map +1 -1
  144. package/dist/react/FileDiff.js +4 -2
  145. package/dist/react/FileDiff.js.map +1 -1
  146. package/dist/react/MultiFileDiff.d.ts +7 -5
  147. package/dist/react/MultiFileDiff.d.ts.map +1 -1
  148. package/dist/react/MultiFileDiff.js +4 -2
  149. package/dist/react/MultiFileDiff.js.map +1 -1
  150. package/dist/react/PatchDiff.d.ts +4 -1
  151. package/dist/react/PatchDiff.d.ts.map +1 -1
  152. package/dist/react/PatchDiff.js +4 -2
  153. package/dist/react/PatchDiff.js.map +1 -1
  154. package/dist/react/UnresolvedFile.d.ts +1 -0
  155. package/dist/react/UnresolvedFile.d.ts.map +1 -1
  156. package/dist/react/UnresolvedFile.js +2 -1
  157. package/dist/react/UnresolvedFile.js.map +1 -1
  158. package/dist/react/index.d.ts +3 -2
  159. package/dist/react/index.js +2 -1
  160. package/dist/react/types.d.ts +3 -0
  161. package/dist/react/types.d.ts.map +1 -1
  162. package/dist/react/utils/renderDiffChildren.d.ts +2 -0
  163. package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
  164. package/dist/react/utils/renderDiffChildren.js +16 -8
  165. package/dist/react/utils/renderDiffChildren.js.map +1 -1
  166. package/dist/react/utils/renderFileChildren.d.ts +2 -0
  167. package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
  168. package/dist/react/utils/renderFileChildren.js +16 -8
  169. package/dist/react/utils/renderFileChildren.js.map +1 -1
  170. package/dist/react/utils/useFileDiffInstance.d.ts +3 -1
  171. package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
  172. package/dist/react/utils/useFileDiffInstance.js +30 -6
  173. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  174. package/dist/react/utils/useFileInstance.d.ts +4 -1
  175. package/dist/react/utils/useFileInstance.d.ts.map +1 -1
  176. package/dist/react/utils/useFileInstance.js +30 -5
  177. package/dist/react/utils/useFileInstance.js.map +1 -1
  178. package/dist/renderers/DiffHunksRenderer.d.ts +28 -2
  179. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  180. package/dist/renderers/DiffHunksRenderer.js +244 -22
  181. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  182. package/dist/renderers/FileRenderer.d.ts +8 -1
  183. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  184. package/dist/renderers/FileRenderer.js +155 -45
  185. package/dist/renderers/FileRenderer.js.map +1 -1
  186. package/dist/ssr/index.d.ts +2 -2
  187. package/dist/ssr/preloadDiffs.d.ts +11 -10
  188. package/dist/ssr/preloadDiffs.d.ts.map +1 -1
  189. package/dist/ssr/preloadDiffs.js +15 -7
  190. package/dist/ssr/preloadDiffs.js.map +1 -1
  191. package/dist/style.js +1 -1
  192. package/dist/types.d.ts +282 -5
  193. package/dist/types.d.ts.map +1 -1
  194. package/dist/utils/applyLineTextWithNewline.d.ts +5 -0
  195. package/dist/utils/applyLineTextWithNewline.d.ts.map +1 -0
  196. package/dist/utils/applyLineTextWithNewline.js +11 -0
  197. package/dist/utils/applyLineTextWithNewline.js.map +1 -0
  198. package/dist/utils/areHunkDataEqual.js +1 -1
  199. package/dist/utils/areHunkDataEqual.js.map +1 -1
  200. package/dist/utils/areManagedSnapshotsEqual.d.ts +2 -2
  201. package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -1
  202. package/dist/utils/areManagedSnapshotsEqual.js +5 -0
  203. package/dist/utils/areManagedSnapshotsEqual.js.map +1 -1
  204. package/dist/utils/awaitWithTimeout.d.ts +5 -0
  205. package/dist/utils/awaitWithTimeout.d.ts.map +1 -0
  206. package/dist/utils/awaitWithTimeout.js +15 -0
  207. package/dist/utils/awaitWithTimeout.js.map +1 -0
  208. package/dist/utils/cleanLastNewline.js +6 -1
  209. package/dist/utils/cleanLastNewline.js.map +1 -1
  210. package/dist/utils/cloneFileDiffMetadata.d.ts +7 -0
  211. package/dist/utils/cloneFileDiffMetadata.d.ts.map +1 -0
  212. package/dist/utils/cloneFileDiffMetadata.js +16 -0
  213. package/dist/utils/cloneFileDiffMetadata.js.map +1 -0
  214. package/dist/utils/computeEstimatedDiffHeights.d.ts +3 -1
  215. package/dist/utils/computeEstimatedDiffHeights.d.ts.map +1 -1
  216. package/dist/utils/computeEstimatedDiffHeights.js +8 -1
  217. package/dist/utils/computeEstimatedDiffHeights.js.map +1 -1
  218. package/dist/utils/computeFileOffsets.d.ts +21 -0
  219. package/dist/utils/computeFileOffsets.d.ts.map +1 -0
  220. package/dist/utils/computeFileOffsets.js +51 -0
  221. package/dist/utils/computeFileOffsets.js.map +1 -0
  222. package/dist/utils/createCodeViewHeaderFooterHostElement.d.ts +5 -0
  223. package/dist/utils/createCodeViewHeaderFooterHostElement.d.ts.map +1 -0
  224. package/dist/utils/createCodeViewHeaderFooterHostElement.js +19 -0
  225. package/dist/utils/createCodeViewHeaderFooterHostElement.js.map +1 -0
  226. package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
  227. package/dist/utils/createFileHeaderElement.js +5 -1
  228. package/dist/utils/createFileHeaderElement.js.map +1 -1
  229. package/dist/utils/createTransformerWithState.js +9 -0
  230. package/dist/utils/createTransformerWithState.js.map +1 -1
  231. package/dist/utils/editSessionHunks.d.ts +84 -0
  232. package/dist/utils/editSessionHunks.d.ts.map +1 -0
  233. package/dist/utils/editSessionHunks.js +366 -0
  234. package/dist/utils/editSessionHunks.js.map +1 -0
  235. package/dist/utils/getDiffFileInput.d.ts +14 -0
  236. package/dist/utils/getDiffFileInput.d.ts.map +1 -0
  237. package/dist/utils/getDiffFileInput.js +24 -0
  238. package/dist/utils/getDiffFileInput.js.map +1 -0
  239. package/dist/utils/getDiffHunksRendererOptions.js +1 -0
  240. package/dist/utils/getDiffHunksRendererOptions.js.map +1 -1
  241. package/dist/utils/getFiletypeFromFileName.d.ts.map +1 -1
  242. package/dist/utils/getFiletypeFromFileName.js +2 -0
  243. package/dist/utils/getFiletypeFromFileName.js.map +1 -1
  244. package/dist/utils/hydratePartialDiff.d.ts +10 -0
  245. package/dist/utils/hydratePartialDiff.d.ts.map +1 -0
  246. package/dist/utils/hydratePartialDiff.js +140 -0
  247. package/dist/utils/hydratePartialDiff.js.map +1 -0
  248. package/dist/utils/iterateOverDiff.js +3 -3
  249. package/dist/utils/iterateOverDiff.js.map +1 -1
  250. package/dist/utils/parseDiffFromFile.d.ts +1 -1
  251. package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
  252. package/dist/utils/parseDiffFromFile.js +26 -5
  253. package/dist/utils/parseDiffFromFile.js.map +1 -1
  254. package/dist/utils/parsePatchFiles.d.ts.map +1 -1
  255. package/dist/utils/parsePatchFiles.js +2 -0
  256. package/dist/utils/parsePatchFiles.js.map +1 -1
  257. package/dist/utils/realignChangeContent.d.ts +28 -0
  258. package/dist/utils/realignChangeContent.d.ts.map +1 -0
  259. package/dist/utils/realignChangeContent.js +142 -0
  260. package/dist/utils/realignChangeContent.js.map +1 -0
  261. package/dist/utils/renderDiffWithHighlighter.js +1 -1
  262. package/dist/utils/renderFileWithHighlighter.d.ts.map +1 -1
  263. package/dist/utils/renderFileWithHighlighter.js +5 -14
  264. package/dist/utils/renderFileWithHighlighter.js.map +1 -1
  265. package/dist/utils/updateDiffHunks.d.ts +24 -0
  266. package/dist/utils/updateDiffHunks.d.ts.map +1 -0
  267. package/dist/utils/updateDiffHunks.js +235 -0
  268. package/dist/utils/updateDiffHunks.js.map +1 -0
  269. package/dist/utils/virtualDiffLayout.d.ts +40 -1
  270. package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
  271. package/dist/utils/virtualDiffLayout.js +96 -1
  272. package/dist/utils/virtualDiffLayout.js.map +1 -1
  273. package/dist/worker/WorkerPoolManager.d.ts +7 -2
  274. package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
  275. package/dist/worker/WorkerPoolManager.js +83 -18
  276. package/dist/worker/WorkerPoolManager.js.map +1 -1
  277. package/dist/worker/index.d.ts +2 -2
  278. package/dist/worker/types.d.ts +11 -1
  279. package/dist/worker/types.d.ts.map +1 -1
  280. package/dist/worker/worker-portable.js +46 -66
  281. package/dist/worker/worker-portable.js.map +1 -1
  282. package/dist/worker/worker.js +46 -66
  283. package/dist/worker/worker.js.map +1 -1
  284. package/package.json +12 -5
  285. package/dist/utils/iterateOverFile.d.ts +0 -50
  286. package/dist/utils/iterateOverFile.d.ts.map +0 -1
  287. package/dist/utils/iterateOverFile.js +0 -49
  288. 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 { getExpandedRegion, getLeadingHunkSeparatorLayout, getTrailingExpandedRegion, getTrailingHunkSeparatorLayout } from "../utils/virtualDiffLayout.js";
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 LAYOUT_CHECKPOINT_INTERVAL = 5e3;
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) this.resetLayoutCache({ includeEstimatedHeights: true });
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.hunksRenderer.expandHunk(hunkIndex, direction, expansionLineCountOverride);
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
- computeApproximateSize(force = false) {
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 (this.fileDiff == null) {
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 (this.fileDiff == null) {
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: this.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 || this.fileDiff == null) return;
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: this.fileDiff.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, oldFile, newFile, fileDiff, forceRender = false, lineAnnotations, ...props } = {}) {
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
- this.fileDiff ??= fileDiff ?? (oldFile != null && newFile != null ? parseDiffFromFile(oldFile, newFile, this.options.parseDiffOptions) : void 0);
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 (this.fileDiff == null) {
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 this.top ??= this.getVirtualizedTop();
442
- if (!this.isVisible && this.isSimpleMode()) return this.renderPlaceholder(this.height);
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(this.fileDiff, fileTop, windowSpecs);
446
- return super.render({
447
- fileDiff: this.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
- ...props
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 || this.fileDiff == null || this.fileDiff.hunks.length === 0 || this.options.collapsed === true) return;
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 = this.fileDiff.hunks.length - 1;
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 += LAYOUT_CHECKPOINT_INTERVAL;
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 < this.fileDiff.hunks.length; hunkIndex++) {
514
- const hunk = this.fileDiff.hunks[hunkIndex];
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: this.fileDiff.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: this.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.cache.totalLines > 0 ? this.cache.totalLines : this.getExpandedLineCount(fileDiff, diffStyle);
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.cache.totalLines > 0 ? this.cache.totalLines : lineCount;
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) absoluteLineTop += getTrailingHunkSeparatorLayout({
714
- type: hunkSeparators,
715
- metrics: this.metrics
716
- })?.totalHeight ?? 0;
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 / LAYOUT_CHECKPOINT_INTERVAL) * LAYOUT_CHECKPOINT_INTERVAL;
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