@pierre/diffs 1.1.0-beta.6 → 1.1.0-beta.8

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 (291) hide show
  1. package/dist/components/AdvancedVirtualizedFileDiff.d.ts +40 -0
  2. package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +1 -0
  3. package/dist/components/AdvancedVirtualizedFileDiff.js +145 -0
  4. package/dist/components/AdvancedVirtualizedFileDiff.js.map +1 -0
  5. package/dist/components/AdvancedVirtualizer.d.ts +38 -0
  6. package/dist/components/AdvancedVirtualizer.d.ts.map +1 -0
  7. package/dist/components/AdvancedVirtualizer.js +201 -0
  8. package/dist/components/AdvancedVirtualizer.js.map +1 -0
  9. package/dist/components/File.d.ts +58 -33
  10. package/dist/components/File.d.ts.map +1 -1
  11. package/dist/components/File.js +223 -22
  12. package/dist/components/File.js.map +1 -1
  13. package/dist/components/FileDiff.d.ts +42 -16
  14. package/dist/components/FileDiff.d.ts.map +1 -1
  15. package/dist/components/FileDiff.js +505 -65
  16. package/dist/components/FileDiff.js.map +1 -1
  17. package/dist/components/FileStream.d.ts +5 -0
  18. package/dist/components/FileStream.d.ts.map +1 -1
  19. package/dist/components/FileStream.js +66 -8
  20. package/dist/components/FileStream.js.map +1 -1
  21. package/dist/components/VirtualizedFile.d.ts +33 -0
  22. package/dist/components/VirtualizedFile.d.ts.map +1 -0
  23. package/dist/components/VirtualizedFile.js +227 -0
  24. package/dist/components/VirtualizedFile.js.map +1 -0
  25. package/dist/components/VirtualizedFileDiff.d.ts +39 -0
  26. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -0
  27. package/dist/components/VirtualizedFileDiff.js +316 -0
  28. package/dist/components/VirtualizedFileDiff.js.map +1 -0
  29. package/dist/components/Virtualizer.d.ts +63 -0
  30. package/dist/components/Virtualizer.d.ts.map +1 -0
  31. package/dist/components/Virtualizer.js +369 -0
  32. package/dist/components/Virtualizer.js.map +1 -0
  33. package/dist/components/VirtulizerDevelopment.d.ts +14 -0
  34. package/dist/components/VirtulizerDevelopment.d.ts.map +1 -0
  35. package/dist/components/web-components.d.ts +1 -1
  36. package/dist/components/web-components.d.ts.map +1 -1
  37. package/dist/constants.d.ts +4 -7
  38. package/dist/constants.d.ts.map +1 -1
  39. package/dist/constants.js +14 -6
  40. package/dist/constants.js.map +1 -1
  41. package/dist/highlighter/languages/areLanguagesAttached.d.ts.map +1 -1
  42. package/dist/highlighter/languages/attachResolvedLanguages.d.ts.map +1 -1
  43. package/dist/highlighter/languages/cleanUpResolvedLanguages.d.ts.map +1 -1
  44. package/dist/highlighter/languages/constants.d.ts.map +1 -1
  45. package/dist/highlighter/languages/getResolvedLanguages.d.ts.map +1 -1
  46. package/dist/highlighter/languages/getResolvedOrResolveLanguage.d.ts +1 -1
  47. package/dist/highlighter/languages/getResolvedOrResolveLanguage.d.ts.map +1 -1
  48. package/dist/highlighter/languages/hasResolvedLanguages.d.ts.map +1 -1
  49. package/dist/highlighter/languages/registerCustomLanguage.d.ts +11 -4
  50. package/dist/highlighter/languages/registerCustomLanguage.d.ts.map +1 -1
  51. package/dist/highlighter/languages/resolveLanguage.d.ts +1 -1
  52. package/dist/highlighter/languages/resolveLanguage.d.ts.map +1 -1
  53. package/dist/highlighter/languages/resolveLanguages.d.ts.map +1 -1
  54. package/dist/highlighter/shared_highlighter.d.ts.map +1 -1
  55. package/dist/highlighter/shared_highlighter.js.map +1 -1
  56. package/dist/highlighter/themes/areThemesAttached.d.ts.map +1 -1
  57. package/dist/highlighter/themes/attachResolvedThemes.d.ts.map +1 -1
  58. package/dist/highlighter/themes/cleanUpResolvedThemes.d.ts.map +1 -1
  59. package/dist/highlighter/themes/constants.d.ts.map +1 -1
  60. package/dist/highlighter/themes/getResolvedOrResolveTheme.d.ts.map +1 -1
  61. package/dist/highlighter/themes/getResolvedThemes.d.ts.map +1 -1
  62. package/dist/highlighter/themes/hasResolvedThemes.d.ts.map +1 -1
  63. package/dist/highlighter/themes/registerCustomCSSVariableTheme.d.ts.map +1 -1
  64. package/dist/highlighter/themes/registerCustomTheme.d.ts.map +1 -1
  65. package/dist/highlighter/themes/resolveTheme.d.ts.map +1 -1
  66. package/dist/highlighter/themes/resolveThemes.d.ts.map +1 -1
  67. package/dist/index.d.ts +13 -10
  68. package/dist/index.js +10 -7
  69. package/dist/managers/LineSelectionManager.d.ts +14 -15
  70. package/dist/managers/LineSelectionManager.d.ts.map +1 -1
  71. package/dist/managers/LineSelectionManager.js +60 -71
  72. package/dist/managers/LineSelectionManager.js.map +1 -1
  73. package/dist/managers/MouseEventManager.d.ts +13 -6
  74. package/dist/managers/MouseEventManager.d.ts.map +1 -1
  75. package/dist/managers/MouseEventManager.js +161 -47
  76. package/dist/managers/MouseEventManager.js.map +1 -1
  77. package/dist/managers/ResizeManager.d.ts +6 -1
  78. package/dist/managers/ResizeManager.d.ts.map +1 -1
  79. package/dist/managers/ResizeManager.js +114 -64
  80. package/dist/managers/ResizeManager.js.map +1 -1
  81. package/dist/managers/ScrollSyncManager.d.ts.map +1 -1
  82. package/dist/managers/UniversalRenderingManager.d.ts.map +1 -1
  83. package/dist/react/File.d.ts +1 -0
  84. package/dist/react/File.d.ts.map +1 -1
  85. package/dist/react/File.js +2 -1
  86. package/dist/react/File.js.map +1 -1
  87. package/dist/react/FileDiff.d.ts +1 -0
  88. package/dist/react/FileDiff.d.ts.map +1 -1
  89. package/dist/react/FileDiff.js +2 -1
  90. package/dist/react/FileDiff.js.map +1 -1
  91. package/dist/react/MultiFileDiff.d.ts +1 -0
  92. package/dist/react/MultiFileDiff.d.ts.map +1 -1
  93. package/dist/react/MultiFileDiff.js +2 -1
  94. package/dist/react/MultiFileDiff.js.map +1 -1
  95. package/dist/react/PatchDiff.d.ts +1 -0
  96. package/dist/react/PatchDiff.d.ts.map +1 -1
  97. package/dist/react/PatchDiff.js +3 -2
  98. package/dist/react/PatchDiff.js.map +1 -1
  99. package/dist/react/Virtualizer.d.ts +25 -0
  100. package/dist/react/Virtualizer.d.ts.map +1 -0
  101. package/dist/react/Virtualizer.js +38 -0
  102. package/dist/react/Virtualizer.js.map +1 -0
  103. package/dist/react/WorkerPoolContext.d.ts.map +1 -1
  104. package/dist/react/WorkerPoolContext.js +1 -1
  105. package/dist/react/WorkerPoolContext.js.map +1 -1
  106. package/dist/react/constants.d.ts.map +1 -1
  107. package/dist/react/index.d.ts +3 -2
  108. package/dist/react/index.js +2 -1
  109. package/dist/react/jsx.d.ts.map +1 -1
  110. package/dist/react/types.d.ts +5 -3
  111. package/dist/react/types.d.ts.map +1 -1
  112. package/dist/react/utils/renderDiffChildren.d.ts +5 -5
  113. package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
  114. package/dist/react/utils/renderFileChildren.d.ts +5 -5
  115. package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
  116. package/dist/react/utils/templateRender.d.ts.map +1 -1
  117. package/dist/react/utils/useFileDiffInstance.d.ts +5 -3
  118. package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
  119. package/dist/react/utils/useFileDiffInstance.js +6 -2
  120. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  121. package/dist/react/utils/useFileInstance.d.ts +5 -3
  122. package/dist/react/utils/useFileInstance.d.ts.map +1 -1
  123. package/dist/react/utils/useFileInstance.js +6 -2
  124. package/dist/react/utils/useFileInstance.js.map +1 -1
  125. package/dist/react/utils/useStableCallback.d.ts.map +1 -1
  126. package/dist/react/utils/useStableCallback.js.map +1 -1
  127. package/dist/renderers/DiffHunksRenderer.d.ts +15 -10
  128. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  129. package/dist/renderers/DiffHunksRenderer.js +240 -136
  130. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  131. package/dist/renderers/FileRenderer.d.ts +12 -5
  132. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  133. package/dist/renderers/FileRenderer.js +90 -31
  134. package/dist/renderers/FileRenderer.js.map +1 -1
  135. package/dist/shiki-stream/stream.d.ts +2 -2
  136. package/dist/shiki-stream/stream.d.ts.map +1 -1
  137. package/dist/shiki-stream/stream.js.map +1 -1
  138. package/dist/shiki-stream/tokenizer.d.ts +2 -2
  139. package/dist/shiki-stream/tokenizer.d.ts.map +1 -1
  140. package/dist/shiki-stream/tokenizer.js.map +1 -1
  141. package/dist/shiki-stream/types.d.ts +18 -18
  142. package/dist/shiki-stream/types.d.ts.map +1 -1
  143. package/dist/sprite.d.ts +1 -1
  144. package/dist/sprite.d.ts.map +1 -1
  145. package/dist/ssr/FileDiffReact.d.ts.map +1 -1
  146. package/dist/ssr/FileDiffReact.js +1 -1
  147. package/dist/ssr/index.d.ts +2 -2
  148. package/dist/ssr/preloadDiffs.d.ts.map +1 -1
  149. package/dist/ssr/preloadFile.d.ts.map +1 -1
  150. package/dist/ssr/preloadPatchFile.d.ts.map +1 -1
  151. package/dist/ssr/preloadPatchFile.js.map +1 -1
  152. package/dist/ssr/renderHTML.d.ts.map +1 -1
  153. package/dist/style.js +1 -1
  154. package/dist/style.js.map +1 -1
  155. package/dist/types.d.ts +191 -172
  156. package/dist/types.d.ts.map +1 -1
  157. package/dist/utils/areDiffLineAnnotationsEqual.d.ts.map +1 -1
  158. package/dist/utils/areDiffLineAnnotationsEqual.js.map +1 -1
  159. package/dist/utils/areFilesEqual.d.ts.map +1 -1
  160. package/dist/utils/areHunkDataEqual.d.ts.map +1 -1
  161. package/dist/utils/areLineAnnotationsEqual.d.ts.map +1 -1
  162. package/dist/utils/areObjectsEqual.d.ts.map +1 -1
  163. package/dist/utils/areOptionsEqual.d.ts +1 -1
  164. package/dist/utils/areOptionsEqual.d.ts.map +1 -1
  165. package/dist/utils/arePrePropertiesEqual.d.ts.map +1 -1
  166. package/dist/utils/arePrePropertiesEqual.js +1 -1
  167. package/dist/utils/arePrePropertiesEqual.js.map +1 -1
  168. package/dist/utils/areRenderRangesEqual.d.ts.map +1 -1
  169. package/dist/utils/areSelectionsEqual.d.ts.map +1 -1
  170. package/dist/utils/areThemesEqual.d.ts.map +1 -1
  171. package/dist/utils/areVirtualWindowSpecsEqual.d.ts.map +1 -1
  172. package/dist/utils/areWorkerStatsEqual.d.ts.map +1 -1
  173. package/dist/utils/cleanLastNewline.d.ts.map +1 -1
  174. package/dist/utils/createAnnotationElement.d.ts.map +1 -1
  175. package/dist/utils/createAnnotationWrapperNode.d.ts.map +1 -1
  176. package/dist/utils/createContentColumn.d.ts +7 -0
  177. package/dist/utils/createContentColumn.d.ts.map +1 -0
  178. package/dist/utils/createContentColumn.js +17 -0
  179. package/dist/utils/createContentColumn.js.map +1 -0
  180. package/dist/utils/createEmptyRowBuffer.d.ts.map +1 -1
  181. package/dist/utils/createEmptyRowBuffer.js +2 -1
  182. package/dist/utils/createEmptyRowBuffer.js.map +1 -1
  183. package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
  184. package/dist/utils/createHoverContentNode.d.ts.map +1 -1
  185. package/dist/utils/createNoNewlineElement.d.ts +2 -1
  186. package/dist/utils/createNoNewlineElement.d.ts.map +1 -1
  187. package/dist/utils/createNoNewlineElement.js +3 -6
  188. package/dist/utils/createNoNewlineElement.js.map +1 -1
  189. package/dist/utils/createPreElement.d.ts +2 -1
  190. package/dist/utils/createPreElement.d.ts.map +1 -1
  191. package/dist/utils/createPreElement.js +4 -3
  192. package/dist/utils/createPreElement.js.map +1 -1
  193. package/dist/utils/createRowNodes.d.ts.map +1 -1
  194. package/dist/utils/createSeparator.d.ts.map +1 -1
  195. package/dist/utils/createSeparator.js +1 -1
  196. package/dist/utils/createSeparator.js.map +1 -1
  197. package/dist/utils/createSpanNodeFromToken.d.ts.map +1 -1
  198. package/dist/utils/createSpanNodeFromToken.js.map +1 -1
  199. package/dist/utils/createStyleElement.d.ts.map +1 -1
  200. package/dist/utils/createTransformerWithState.d.ts.map +1 -1
  201. package/dist/utils/createUnsafeCSSStyleNode.d.ts.map +1 -1
  202. package/dist/utils/createWindowFromScrollPosition.d.ts.map +1 -1
  203. package/dist/utils/cssWrappers.d.ts.map +1 -1
  204. package/dist/utils/diffAcceptRejectHunk.d.ts +1 -1
  205. package/dist/utils/diffAcceptRejectHunk.d.ts.map +1 -1
  206. package/dist/utils/formatCSSVariablePrefix.d.ts +1 -1
  207. package/dist/utils/formatCSSVariablePrefix.d.ts.map +1 -1
  208. package/dist/utils/getFiletypeFromFileName.d.ts.map +1 -1
  209. package/dist/utils/getHighlighterOptions.d.ts.map +1 -1
  210. package/dist/utils/getHighlighterThemeStyles.d.ts.map +1 -1
  211. package/dist/utils/getHunkSeparatorSlotName.d.ts +3 -1
  212. package/dist/utils/getHunkSeparatorSlotName.d.ts.map +1 -1
  213. package/dist/utils/getHunkSeparatorSlotName.js.map +1 -1
  214. package/dist/utils/getIconForType.d.ts +1 -1
  215. package/dist/utils/getIconForType.d.ts.map +1 -1
  216. package/dist/utils/getLineAnnotationName.d.ts.map +1 -1
  217. package/dist/utils/getLineEndingType.d.ts +1 -1
  218. package/dist/utils/getLineEndingType.d.ts.map +1 -1
  219. package/dist/utils/getLineNodes.d.ts.map +1 -1
  220. package/dist/utils/getOrCreateCodeNode.d.ts +4 -2
  221. package/dist/utils/getOrCreateCodeNode.d.ts.map +1 -1
  222. package/dist/utils/getOrCreateCodeNode.js +9 -6
  223. package/dist/utils/getOrCreateCodeNode.js.map +1 -1
  224. package/dist/utils/getSingularPatch.d.ts.map +1 -1
  225. package/dist/utils/getThemes.d.ts.map +1 -1
  226. package/dist/utils/getTotalLineCountFromHunks.d.ts.map +1 -1
  227. package/dist/utils/hast_utils.d.ts +6 -3
  228. package/dist/utils/hast_utils.d.ts.map +1 -1
  229. package/dist/utils/hast_utils.js +28 -4
  230. package/dist/utils/hast_utils.js.map +1 -1
  231. package/dist/utils/isDefaultRenderRange.d.ts.map +1 -1
  232. package/dist/utils/isWorkerContext.d.ts.map +1 -1
  233. package/dist/utils/iterateOverDiff.d.ts +26 -13
  234. package/dist/utils/iterateOverDiff.d.ts.map +1 -1
  235. package/dist/utils/iterateOverDiff.js +94 -55
  236. package/dist/utils/iterateOverDiff.js.map +1 -1
  237. package/dist/utils/iterateOverFile.d.ts +50 -0
  238. package/dist/utils/iterateOverFile.d.ts.map +1 -0
  239. package/dist/utils/iterateOverFile.js +49 -0
  240. package/dist/utils/iterateOverFile.js.map +1 -0
  241. package/dist/utils/parseDiffDecorations.d.ts.map +1 -1
  242. package/dist/utils/parseDiffFromFile.d.ts +6 -6
  243. package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
  244. package/dist/utils/parseDiffFromFile.js +3 -2
  245. package/dist/utils/parseDiffFromFile.js.map +1 -1
  246. package/dist/utils/parseLineType.d.ts +1 -1
  247. package/dist/utils/parseLineType.d.ts.map +1 -1
  248. package/dist/utils/parsePatchFiles.d.ts +12 -10
  249. package/dist/utils/parsePatchFiles.d.ts.map +1 -1
  250. package/dist/utils/parsePatchFiles.js +16 -9
  251. package/dist/utils/parsePatchFiles.js.map +1 -1
  252. package/dist/utils/prerenderHTMLIfNecessary.d.ts.map +1 -1
  253. package/dist/utils/processLine.d.ts.map +1 -1
  254. package/dist/utils/processLine.js +7 -24
  255. package/dist/utils/processLine.js.map +1 -1
  256. package/dist/utils/renderDiffWithHighlighter.d.ts +2 -2
  257. package/dist/utils/renderDiffWithHighlighter.d.ts.map +1 -1
  258. package/dist/utils/renderDiffWithHighlighter.js +15 -14
  259. package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
  260. package/dist/utils/renderFileWithHighlighter.d.ts +7 -2
  261. package/dist/utils/renderFileWithHighlighter.d.ts.map +1 -1
  262. package/dist/utils/renderFileWithHighlighter.js +30 -4
  263. package/dist/utils/renderFileWithHighlighter.js.map +1 -1
  264. package/dist/utils/resolveVirtualFileMetrics.d.ts +7 -0
  265. package/dist/utils/resolveVirtualFileMetrics.d.ts.map +1 -0
  266. package/dist/utils/resolveVirtualFileMetrics.js +24 -0
  267. package/dist/utils/resolveVirtualFileMetrics.js.map +1 -0
  268. package/dist/utils/setLanguageOverride.d.ts.map +1 -1
  269. package/dist/utils/setWrapperNodeProps.d.ts +1 -0
  270. package/dist/utils/setWrapperNodeProps.d.ts.map +1 -1
  271. package/dist/utils/setWrapperNodeProps.js +19 -12
  272. package/dist/utils/setWrapperNodeProps.js.map +1 -1
  273. package/dist/utils/splitFileContents.d.ts +12 -0
  274. package/dist/utils/splitFileContents.d.ts.map +1 -0
  275. package/dist/utils/splitFileContents.js +17 -0
  276. package/dist/utils/splitFileContents.js.map +1 -0
  277. package/dist/utils/trimPatchContext.d.ts +5 -5
  278. package/dist/utils/trimPatchContext.d.ts.map +1 -1
  279. package/dist/worker/WorkerPoolManager.d.ts +2 -2
  280. package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
  281. package/dist/worker/WorkerPoolManager.js +36 -24
  282. package/dist/worker/WorkerPoolManager.js.map +1 -1
  283. package/dist/worker/getOrCreateWorkerPoolSingleton.d.ts.map +1 -1
  284. package/dist/worker/getOrCreateWorkerPoolSingleton.js.map +1 -1
  285. package/dist/worker/types.d.ts +26 -26
  286. package/dist/worker/types.d.ts.map +1 -1
  287. package/dist/worker/worker-portable.js +323 -143
  288. package/dist/worker/worker-portable.js.map +1 -1
  289. package/dist/worker/worker.js +206 -106
  290. package/dist/worker/worker.js.map +1 -1
  291. package/package.json +52 -53
@@ -1,16 +1,17 @@
1
- import { DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_THEMES } from "../constants.js";
1
+ import { DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES } from "../constants.js";
2
2
  import { areLanguagesAttached } from "../highlighter/languages/areLanguagesAttached.js";
3
3
  import { getHighlighterIfLoaded, getSharedHighlighter } from "../highlighter/shared_highlighter.js";
4
4
  import { areThemesAttached } from "../highlighter/themes/areThemesAttached.js";
5
+ import { areRenderRangesEqual } from "../utils/areRenderRangesEqual.js";
5
6
  import { areThemesEqual } from "../utils/areThemesEqual.js";
6
- import { createBufferElement, createHastElement } from "../utils/hast_utils.js";
7
+ import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement } from "../utils/hast_utils.js";
7
8
  import { createAnnotationElement } from "../utils/createAnnotationElement.js";
9
+ import { createContentColumn } from "../utils/createContentColumn.js";
8
10
  import { createFileHeaderElement } from "../utils/createFileHeaderElement.js";
9
11
  import { createPreElement } from "../utils/createPreElement.js";
10
12
  import { getFiletypeFromFileName } from "../utils/getFiletypeFromFileName.js";
11
13
  import { getHighlighterOptions } from "../utils/getHighlighterOptions.js";
12
14
  import { getLineAnnotationName } from "../utils/getLineAnnotationName.js";
13
- import { areRenderRangesEqual } from "../utils/areRenderRangesEqual.js";
14
15
  import { createEmptyRowBuffer } from "../utils/createEmptyRowBuffer.js";
15
16
  import { createNoNewlineElement } from "../utils/createNoNewlineElement.js";
16
17
  import { createSeparator } from "../utils/createSeparator.js";
@@ -22,12 +23,6 @@ import { renderDiffWithHighlighter } from "../utils/renderDiffWithHighlighter.js
22
23
  import { toHtml } from "hast-util-to-html";
23
24
 
24
25
  //#region src/renderers/DiffHunksRenderer.ts
25
- const DEFAULT_RENDER_RANGE = {
26
- startingLine: 0,
27
- totalLines: Infinity,
28
- bufferBefore: 0,
29
- bufferAfter: 0
30
- };
31
26
  let instanceId = -1;
32
27
  var DiffHunksRenderer = class {
33
28
  __id = `diff-hunks-renderer:${++instanceId}`;
@@ -222,6 +217,7 @@ var DiffHunksRenderer = class {
222
217
  createPreElement(split, totalLines, themeStyles, baseThemeType) {
223
218
  const { diffIndicators, disableBackground, disableLineNumbers, overflow, themeType } = this.getOptionsWithDefaults();
224
219
  return createPreElement({
220
+ type: "diff",
225
221
  diffIndicators,
226
222
  disableBackground,
227
223
  disableLineNumbers,
@@ -267,50 +263,71 @@ var DiffHunksRenderer = class {
267
263
  console.error(error);
268
264
  }
269
265
  processDiffResult(fileDiff, renderRange, { code, themeStyles, baseThemeType }) {
270
- const { diffStyle, disableFileHeader, disableVirtualizationBuffers, expandUnchanged, expansionLineCount, collapsedContextThreshold, hunkSeparators } = this.getOptionsWithDefaults();
266
+ const { diffStyle, disableFileHeader, expandUnchanged, expansionLineCount, collapsedContextThreshold, hunkSeparators } = this.getOptionsWithDefaults();
271
267
  this.diff = fileDiff;
272
268
  const unified = diffStyle === "unified";
273
- let additionsAST = [];
274
- let deletionsAST = [];
275
- let unifiedAST = [];
269
+ let additionsContentAST = [];
270
+ let deletionsContentAST = [];
271
+ let unifiedContentAST = [];
276
272
  const hunkData = [];
277
273
  const { additionLines, deletionLines } = code;
278
- const separatorContext = {
274
+ const context = {
275
+ rowCount: 0,
279
276
  hunkSeparators,
280
- additionsAST,
281
- deletionsAST,
282
- unifiedAST,
277
+ additionsContentAST,
278
+ deletionsContentAST,
279
+ unifiedContentAST,
280
+ unifiedGutterAST: createGutterWrapper(),
281
+ deletionsGutterAST: createGutterWrapper(),
282
+ additionsGutterAST: createGutterWrapper(),
283
283
  expansionLineCount,
284
- hunkData
284
+ hunkData,
285
+ incrementRowCount(count = 1) {
286
+ context.rowCount += count;
287
+ },
288
+ pushToGutter(type, element) {
289
+ switch (type) {
290
+ case "unified":
291
+ context.unifiedGutterAST.children.push(element);
292
+ break;
293
+ case "deletions":
294
+ context.deletionsGutterAST.children.push(element);
295
+ break;
296
+ case "additions":
297
+ context.additionsGutterAST.children.push(element);
298
+ break;
299
+ }
300
+ }
285
301
  };
286
- const trailingRangeSize = (() => {
287
- const lastHunk = fileDiff.hunks.at(-1);
288
- if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) return 0;
289
- const additionRemaining = fileDiff.additionLines.length - (lastHunk.additionLineIndex + lastHunk.additionCount);
290
- const deletionRemaining = fileDiff.deletionLines.length - (lastHunk.deletionLineIndex + lastHunk.deletionCount);
291
- if (additionRemaining !== deletionRemaining) throw new Error(`DiffHunksRenderer.processDiffResult: trailing context mismatch (additions=${additionRemaining}, deletions=${deletionRemaining}) for ${fileDiff.name}`);
292
- return Math.min(additionRemaining, deletionRemaining);
293
- })();
302
+ const trailingRangeSize = calculateTrailingRangeSize(fileDiff);
294
303
  let pendingSplitSpanSize = 0;
295
304
  let pendingSplitMissing;
296
- let lastHunkIndex;
305
+ function pushGutterLineNumber(type, lineType, lineNumber, lineIndex) {
306
+ context.pushToGutter(type, createGutterItem(lineType, lineNumber, lineIndex));
307
+ }
297
308
  function flushSplitSpan() {
309
+ if (diffStyle === "unified") return;
298
310
  if (pendingSplitSpanSize <= 0 || pendingSplitMissing == null) {
299
311
  pendingSplitSpanSize = 0;
300
312
  pendingSplitMissing = void 0;
301
313
  return;
302
314
  }
303
- if (pendingSplitMissing === "additions") additionsAST?.push(createEmptyRowBuffer(pendingSplitSpanSize));
304
- else deletionsAST?.push(createEmptyRowBuffer(pendingSplitSpanSize));
315
+ if (pendingSplitMissing === "additions") {
316
+ context.pushToGutter("additions", createGutterGap(void 0, "buffer", pendingSplitSpanSize));
317
+ additionsContentAST?.push(createEmptyRowBuffer(pendingSplitSpanSize));
318
+ } else {
319
+ context.pushToGutter("deletions", createGutterGap(void 0, "buffer", pendingSplitSpanSize));
320
+ deletionsContentAST?.push(createEmptyRowBuffer(pendingSplitSpanSize));
321
+ }
305
322
  pendingSplitSpanSize = 0;
306
323
  pendingSplitMissing = void 0;
307
324
  }
308
325
  function pushSeparators(props) {
309
326
  flushSplitSpan();
310
- if (diffStyle === "unified") pushSeparator("unified", props, separatorContext);
327
+ if (diffStyle === "unified") pushSeparator("unified", props, context);
311
328
  else {
312
- pushSeparator("deletions", props, separatorContext);
313
- pushSeparator("additions", props, separatorContext);
329
+ pushSeparator("deletions", props, context);
330
+ pushSeparator("additions", props, context);
314
331
  }
315
332
  }
316
333
  iterateOverDiff({
@@ -320,12 +337,10 @@ var DiffHunksRenderer = class {
320
337
  totalLines: renderRange.totalLines,
321
338
  expandedHunks: expandUnchanged ? true : this.expandedHunks,
322
339
  collapsedContextThreshold,
323
- callback: ({ hunkIndex, hunk, collapsedBefore, collapsedAfter, unifiedDeletionLineIndex, unifiedAdditionLineIndex, splitLineIndex, additionLineIndex, deletionLineIndex, additionLineNumber, deletionLineNumber, type, noEOFCRAddition, noEOFCRDeletion }) => {
324
- if (diffStyle === "split") {
325
- if (lastHunkIndex != null && lastHunkIndex !== hunkIndex) flushSplitSpan();
326
- if (type !== "change") flushSplitSpan();
327
- }
328
- lastHunkIndex = hunkIndex;
340
+ callback: ({ hunkIndex, hunk, collapsedBefore, collapsedAfter, additionLine, deletionLine, type }) => {
341
+ const splitLineIndex = deletionLine != null ? deletionLine.splitLineIndex : additionLine.splitLineIndex;
342
+ const unifiedLineIndex = additionLine != null ? additionLine.unifiedLineIndex : deletionLine.unifiedLineIndex;
343
+ if (diffStyle === "split" && type !== "change") flushSplitSpan();
329
344
  if (collapsedBefore > 0) pushSeparators({
330
345
  hunkIndex,
331
346
  collapsedLines: collapsedBefore,
@@ -335,64 +350,90 @@ var DiffHunksRenderer = class {
335
350
  isLastHunk: false,
336
351
  isExpandable: !fileDiff.isPartial
337
352
  });
338
- const lineIndex = diffStyle === "unified" ? unifiedDeletionLineIndex ?? unifiedAdditionLineIndex : splitLineIndex;
339
- if (lineIndex == null) {
340
- const errorMessage = "DiffHunksRenderer.processDiffResult: iterateOverDiff, no valid line index";
341
- console.error(errorMessage, { file: fileDiff.name });
342
- throw new Error(errorMessage);
343
- }
353
+ const lineIndex = diffStyle === "unified" ? unifiedLineIndex : splitLineIndex;
344
354
  if (diffStyle === "unified") {
345
- const deletionLine = additionLineIndex != null ? void 0 : deletionLineIndex != null ? deletionLines[deletionLineIndex] : void 0;
346
- const additionLine = additionLineIndex != null ? additionLines[additionLineIndex] : void 0;
347
- if (deletionLine == null && additionLine == null) {
355
+ const deletionLineContent = deletionLine != null ? deletionLines[deletionLine.lineIndex] : void 0;
356
+ const additionLineContent = additionLine != null ? additionLines[additionLine.lineIndex] : void 0;
357
+ if (deletionLineContent == null && additionLineContent == null) {
348
358
  const errorMessage = "DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";
349
359
  console.error(errorMessage, { file: fileDiff.name });
350
360
  throw new Error(errorMessage);
351
361
  }
362
+ pushGutterLineNumber("unified", type === "change" ? additionLine != null ? "change-addition" : "change-deletion" : type, additionLine != null ? additionLine.lineNumber : deletionLine.lineNumber, `${unifiedLineIndex},${splitLineIndex}`);
352
363
  pushLineWithAnnotation({
353
- deletionLine,
354
- additionLine,
355
- unifiedAST,
356
- unifiedSpan: this.getAnnotations("unified", deletionLineNumber, additionLineNumber, hunkIndex, lineIndex)
364
+ diffStyle: "unified",
365
+ type,
366
+ deletionLine: deletionLineContent,
367
+ additionLine: additionLineContent,
368
+ unifiedSpan: this.getAnnotations("unified", deletionLine?.lineNumber, additionLine?.lineNumber, hunkIndex, lineIndex),
369
+ context
357
370
  });
358
371
  } else {
359
- const deletionLine = deletionLineIndex != null ? deletionLines[deletionLineIndex] : void 0;
360
- const additionLine = additionLineIndex != null ? additionLines[additionLineIndex] : void 0;
361
- if (deletionLine == null && additionLine == null) {
372
+ const deletionLineContent = deletionLine != null ? deletionLines[deletionLine.lineIndex] : void 0;
373
+ const additionLineContent = additionLine != null ? additionLines[additionLine.lineIndex] : void 0;
374
+ if (deletionLineContent == null && additionLineContent == null) {
362
375
  const errorMessage = "DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";
363
376
  console.error(errorMessage, { file: fileDiff.name });
364
377
  throw new Error(errorMessage);
365
378
  }
366
- const missingSide = deletionLine == null ? "deletions" : additionLine == null ? "additions" : void 0;
379
+ const missingSide = (() => {
380
+ if (type === "change") {
381
+ if (additionLineContent == null) return "additions";
382
+ else if (deletionLineContent == null) return "deletions";
383
+ }
384
+ })();
367
385
  if (missingSide != null) {
368
386
  if (pendingSplitMissing != null && pendingSplitMissing !== missingSide) throw new Error("DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits");
369
387
  pendingSplitMissing = missingSide;
370
388
  pendingSplitSpanSize++;
371
389
  }
372
- const annotationSpans = this.getAnnotations("split", deletionLineNumber, additionLineNumber, hunkIndex, lineIndex);
390
+ const annotationSpans = this.getAnnotations("split", deletionLine?.lineNumber, additionLine?.lineNumber, hunkIndex, lineIndex);
373
391
  if (annotationSpans != null && pendingSplitSpanSize > 0) flushSplitSpan();
392
+ if (deletionLine != null) pushGutterLineNumber("deletions", type === "change" ? "change-deletion" : type, deletionLine.lineNumber, `${deletionLine.unifiedLineIndex},${splitLineIndex}`);
393
+ if (additionLine != null) pushGutterLineNumber("additions", type === "change" ? "change-addition" : type, additionLine.lineNumber, `${additionLine.unifiedLineIndex},${splitLineIndex}`);
374
394
  pushLineWithAnnotation({
375
- additionLine,
376
- deletionLine,
377
- deletionsAST,
378
- additionsAST,
379
- ...annotationSpans
395
+ diffStyle: "split",
396
+ type,
397
+ additionLine: additionLineContent,
398
+ deletionLine: deletionLineContent,
399
+ ...annotationSpans,
400
+ context
380
401
  });
381
402
  }
382
- if (noEOFCRDeletion || noEOFCRAddition) {
383
- const noEOFType = type === "context" || type === "context-expanded" ? "context" : deletionLineIndex != null ? "change-deletion" : "change-addition";
384
- if (noEOFCRDeletion) if (diffStyle === "unified") unifiedAST?.push(createNoNewlineElement(noEOFType));
385
- else {
386
- deletionsAST?.push(createNoNewlineElement("change-deletion"));
387
- if (!noEOFCRAddition) additionsAST?.push(createEmptyRowBuffer(1));
403
+ const noEOFCRDeletion = deletionLine?.noEOFCR ?? false;
404
+ const noEOFCRAddition = additionLine?.noEOFCR ?? false;
405
+ if (noEOFCRAddition || noEOFCRDeletion) {
406
+ if (noEOFCRDeletion) {
407
+ const noEOFType = type === "context" || type === "context-expanded" ? type : "change-deletion";
408
+ if (diffStyle === "unified") {
409
+ context.unifiedContentAST.push(createNoNewlineElement(noEOFType));
410
+ context.pushToGutter("unified", createGutterGap(noEOFType, "metadata", 1));
411
+ } else {
412
+ context.deletionsContentAST.push(createNoNewlineElement(noEOFType));
413
+ context.pushToGutter("deletions", createGutterGap(noEOFType, "metadata", 1));
414
+ if (!noEOFCRAddition) {
415
+ context.pushToGutter("additions", createGutterGap(void 0, "buffer", 1));
416
+ context.additionsContentAST.push(createEmptyRowBuffer(1));
417
+ }
418
+ }
388
419
  }
389
- if (noEOFCRAddition) if (diffStyle === "unified") unifiedAST?.push(createNoNewlineElement("change-addition"));
390
- else {
391
- additionsAST?.push(createNoNewlineElement("change-addition"));
392
- if (!noEOFCRDeletion) deletionsAST?.push(createEmptyRowBuffer(1));
420
+ if (noEOFCRAddition) {
421
+ const noEOFType = type === "context" || type === "context-expanded" ? type : "change-addition";
422
+ if (diffStyle === "unified") {
423
+ context.unifiedContentAST.push(createNoNewlineElement(noEOFType));
424
+ context.pushToGutter("unified", createGutterGap(noEOFType, "metadata", 1));
425
+ } else {
426
+ context.additionsContentAST.push(createNoNewlineElement(noEOFType));
427
+ context.pushToGutter("additions", createGutterGap(noEOFType, "metadata", 1));
428
+ if (!noEOFCRDeletion) {
429
+ context.pushToGutter("deletions", createGutterGap(void 0, "buffer", 1));
430
+ context.deletionsContentAST.push(createEmptyRowBuffer(1));
431
+ }
432
+ }
393
433
  }
434
+ context.incrementRowCount(1);
394
435
  }
395
- if (collapsedAfter > 0) pushSeparators({
436
+ if (collapsedAfter > 0 && hunkSeparators !== "simple") pushSeparators({
396
437
  hunkIndex: type === "context-expanded" ? hunkIndex : hunkIndex + 1,
397
438
  collapsedLines: collapsedAfter,
398
439
  rangeSize: trailingRangeSize,
@@ -401,64 +442,75 @@ var DiffHunksRenderer = class {
401
442
  isLastHunk: true,
402
443
  isExpandable: !fileDiff.isPartial
403
444
  });
445
+ context.incrementRowCount(1);
404
446
  }
405
447
  });
406
448
  if (diffStyle === "split") flushSplitSpan();
407
449
  const totalLines = Math.max(getTotalLineCountFromHunks(fileDiff.hunks), fileDiff.additionLines.length ?? 0, fileDiff.deletionLines.length ?? 0);
408
- additionsAST = !unified && fileDiff.type !== "deleted" ? additionsAST : void 0;
409
- deletionsAST = !unified && fileDiff.type !== "new" ? deletionsAST : void 0;
410
- unifiedAST = unified ? unifiedAST : void 0;
411
- if (!disableVirtualizationBuffers) {
412
- if (renderRange.bufferBefore > 0) {
413
- const element = createBufferElement("before", renderRange.bufferBefore);
414
- unifiedAST?.unshift(element);
415
- deletionsAST?.unshift(element);
416
- additionsAST?.unshift(element);
417
- }
418
- if (renderRange.bufferAfter > 0) {
419
- const element = createBufferElement("after", renderRange.bufferAfter);
420
- unifiedAST?.push(element);
421
- deletionsAST?.push(element);
422
- additionsAST?.push(element);
423
- }
424
- }
425
- if (unifiedAST?.length === 0) unifiedAST = void 0;
426
- if (deletionsAST?.length === 0) deletionsAST = void 0;
427
- if (additionsAST?.length === 0) additionsAST = void 0;
428
- const preNode = this.createPreElement(deletionsAST != null && additionsAST != null, totalLines, themeStyles, baseThemeType);
450
+ const hasBuffer = renderRange.bufferBefore > 0 || renderRange.bufferAfter > 0;
451
+ const shouldIncludeAdditions = !unified && fileDiff.type !== "deleted";
452
+ const shouldIncludeDeletions = !unified && fileDiff.type !== "new";
453
+ const hasContent = context.rowCount > 0 || hasBuffer;
454
+ additionsContentAST = shouldIncludeAdditions && hasContent ? additionsContentAST : void 0;
455
+ deletionsContentAST = shouldIncludeDeletions && hasContent ? deletionsContentAST : void 0;
456
+ unifiedContentAST = unified && hasContent ? unifiedContentAST : void 0;
457
+ const preNode = this.createPreElement(deletionsContentAST != null && additionsContentAST != null, totalLines, themeStyles, baseThemeType);
429
458
  return {
430
- additionsAST,
431
- deletionsAST,
432
- unifiedAST,
459
+ unifiedGutterAST: unified && hasContent ? context.unifiedGutterAST.children : void 0,
460
+ unifiedContentAST,
461
+ deletionsGutterAST: shouldIncludeDeletions && hasContent ? context.deletionsGutterAST.children : void 0,
462
+ deletionsContentAST,
463
+ additionsGutterAST: shouldIncludeAdditions && hasContent ? context.additionsGutterAST.children : void 0,
464
+ additionsContentAST,
433
465
  hunkData,
434
466
  preNode,
435
467
  themeStyles,
436
468
  baseThemeType,
437
469
  headerElement: !disableFileHeader ? this.renderHeader(this.diff, themeStyles, baseThemeType) : void 0,
438
470
  totalLines,
471
+ rowCount: context.rowCount,
472
+ bufferBefore: renderRange.bufferBefore,
473
+ bufferAfter: renderRange.bufferAfter,
439
474
  css: ""
440
475
  };
441
476
  }
477
+ renderCodeAST(type, result) {
478
+ const gutterAST = type === "unified" ? result.unifiedGutterAST : type === "deletions" ? result.deletionsGutterAST : result.additionsGutterAST;
479
+ const contentAST = type === "unified" ? result.unifiedContentAST : type === "deletions" ? result.deletionsContentAST : result.additionsContentAST;
480
+ if (gutterAST == null || contentAST == null) return;
481
+ const gutter = createGutterWrapper(gutterAST);
482
+ gutter.properties.style = `grid-row: span ${result.rowCount}`;
483
+ return [gutter, createContentColumn(contentAST, result.rowCount)];
484
+ }
442
485
  renderFullAST(result, children = []) {
443
- if (result.unifiedAST != null) children.push(createHastElement({
444
- tagName: "code",
445
- children: result.unifiedAST,
446
- properties: {
447
- "data-code": "",
448
- "data-unified": ""
449
- }
450
- }));
451
- if (result.deletionsAST != null) children.push(createHastElement({
486
+ const unifiedAST = this.renderCodeAST("unified", result);
487
+ if (unifiedAST != null) {
488
+ children.push(createHastElement({
489
+ tagName: "code",
490
+ children: unifiedAST,
491
+ properties: {
492
+ "data-code": "",
493
+ "data-unified": ""
494
+ }
495
+ }));
496
+ return {
497
+ ...result.preNode,
498
+ children
499
+ };
500
+ }
501
+ const deletionsAST = this.renderCodeAST("deletions", result);
502
+ if (deletionsAST != null) children.push(createHastElement({
452
503
  tagName: "code",
453
- children: result.deletionsAST,
504
+ children: deletionsAST,
454
505
  properties: {
455
506
  "data-code": "",
456
507
  "data-deletions": ""
457
508
  }
458
509
  }));
459
- if (result.additionsAST != null) children.push(createHastElement({
510
+ const additionsAST = this.renderCodeAST("additions", result);
511
+ if (additionsAST != null) children.push(createHastElement({
460
512
  tagName: "code",
461
- children: result.additionsAST,
513
+ children: additionsAST,
462
514
  properties: {
463
515
  "data-code": "",
464
516
  "data-additions": ""
@@ -523,43 +575,86 @@ function areRenderOptionsEqual(optionsA, optionsB) {
523
575
  function getModifiedLinesString(lines) {
524
576
  return `${lines} unmodified line${lines > 1 ? "s" : ""}`;
525
577
  }
526
- function pushLineWithAnnotation({ deletionLine, additionLine, unifiedAST, additionsAST, deletionsAST, unifiedSpan, deletionSpan, additionSpan }) {
527
- if (unifiedAST != null) {
528
- if (deletionLine != null) unifiedAST.push(deletionLine);
529
- else if (additionLine != null) unifiedAST.push(additionLine);
530
- if (unifiedSpan != null) unifiedAST.push(createAnnotationElement(unifiedSpan));
531
- } else if (deletionsAST != null && additionsAST != null) {
532
- if (deletionLine != null) deletionsAST.push(deletionLine);
533
- if (additionLine != null) additionsAST.push(additionLine);
534
- if (deletionSpan != null) deletionsAST.push(createAnnotationElement(deletionSpan));
535
- if (additionSpan != null) additionsAST.push(createAnnotationElement(additionSpan));
578
+ function pushLineWithAnnotation({ diffStyle, type, deletionLine, additionLine, unifiedSpan, deletionSpan, additionSpan, context }) {
579
+ let hasAnnotationRow = false;
580
+ if (diffStyle === "unified") {
581
+ if (additionLine != null) context.unifiedContentAST.push(additionLine);
582
+ else if (deletionLine != null) context.unifiedContentAST.push(deletionLine);
583
+ if (unifiedSpan != null) {
584
+ const lineType = type === "change" ? deletionLine != null ? "change-deletion" : "change-addition" : type;
585
+ context.unifiedContentAST.push(createAnnotationElement(unifiedSpan));
586
+ context.pushToGutter("unified", createGutterGap(lineType, "annotation", 1));
587
+ hasAnnotationRow = true;
588
+ }
589
+ } else if (diffStyle === "split") {
590
+ if (deletionLine != null) context.deletionsContentAST.push(deletionLine);
591
+ if (additionLine != null) context.additionsContentAST.push(additionLine);
592
+ if (deletionSpan != null) {
593
+ const lineType = type === "change" ? deletionLine != null ? "change-deletion" : "context" : type;
594
+ context.deletionsContentAST.push(createAnnotationElement(deletionSpan));
595
+ context.pushToGutter("deletions", createGutterGap(lineType, "annotation", 1));
596
+ hasAnnotationRow = true;
597
+ }
598
+ if (additionSpan != null) {
599
+ const lineType = type === "change" ? additionLine != null ? "change-addition" : "context" : type;
600
+ context.additionsContentAST.push(createAnnotationElement(additionSpan));
601
+ context.pushToGutter("additions", createGutterGap(lineType, "annotation", 1));
602
+ hasAnnotationRow = true;
603
+ }
536
604
  }
605
+ if (hasAnnotationRow) context.incrementRowCount(1);
537
606
  }
538
- function pushSeparator(type, { hunkIndex, collapsedLines, rangeSize, hunkSpecs, isFirstHunk, isLastHunk, isExpandable }, { expansionLineCount, hunkSeparators, unifiedAST, deletionsAST, additionsAST, hunkData }) {
607
+ function pushSeparator(type, { hunkIndex, collapsedLines, rangeSize, hunkSpecs, isFirstHunk, isLastHunk, isExpandable }, context) {
539
608
  if (collapsedLines <= 0) return;
540
- const linesAST = type === "unified" ? unifiedAST : type === "deletions" ? deletionsAST : additionsAST;
541
- if (hunkSeparators === "metadata") {
542
- if (hunkSpecs != null) linesAST.push(createSeparator({
543
- type: "metadata",
544
- content: hunkSpecs,
545
- isFirstHunk,
546
- isLastHunk
547
- }));
609
+ const linesAST = type === "unified" ? context.unifiedContentAST : type === "deletions" ? context.deletionsContentAST : context.additionsContentAST;
610
+ if (context.hunkSeparators === "metadata") {
611
+ if (hunkSpecs != null) {
612
+ context.pushToGutter(type, createSeparator({
613
+ type: "metadata",
614
+ content: hunkSpecs,
615
+ isFirstHunk,
616
+ isLastHunk
617
+ }));
618
+ linesAST.push(createSeparator({
619
+ type: "metadata",
620
+ content: hunkSpecs,
621
+ isFirstHunk,
622
+ isLastHunk
623
+ }));
624
+ if (type !== "additions") context.incrementRowCount(1);
625
+ }
548
626
  return;
549
627
  }
550
- if (hunkSeparators === "simple") {
551
- if (hunkIndex > 0) linesAST.push(createSeparator({
552
- type: "simple",
553
- isFirstHunk,
554
- isLastHunk: false
555
- }));
628
+ if (context.hunkSeparators === "simple") {
629
+ if (hunkIndex > 0) {
630
+ context.pushToGutter(type, createSeparator({
631
+ type: "simple",
632
+ isFirstHunk,
633
+ isLastHunk: false
634
+ }));
635
+ linesAST.push(createSeparator({
636
+ type: "simple",
637
+ isFirstHunk,
638
+ isLastHunk: false
639
+ }));
640
+ if (type !== "additions") context.incrementRowCount(1);
641
+ }
556
642
  return;
557
643
  }
558
644
  const slotName = getHunkSeparatorSlotName(type, hunkIndex);
559
- const chunked = rangeSize > expansionLineCount;
645
+ const chunked = rangeSize > context.expansionLineCount;
560
646
  const expandIndex = isExpandable ? hunkIndex : void 0;
647
+ context.pushToGutter(type, createSeparator({
648
+ type: context.hunkSeparators,
649
+ content: getModifiedLinesString(collapsedLines),
650
+ expandIndex,
651
+ chunked,
652
+ slotName,
653
+ isFirstHunk,
654
+ isLastHunk
655
+ }));
561
656
  linesAST.push(createSeparator({
562
- type: hunkSeparators,
657
+ type: context.hunkSeparators,
563
658
  content: getModifiedLinesString(collapsedLines),
564
659
  expandIndex,
565
660
  chunked,
@@ -567,7 +662,8 @@ function pushSeparator(type, { hunkIndex, collapsedLines, rangeSize, hunkSpecs,
567
662
  isFirstHunk,
568
663
  isLastHunk
569
664
  }));
570
- hunkData.push({
665
+ if (type !== "additions") context.incrementRowCount(1);
666
+ context.hunkData.push({
571
667
  slotName,
572
668
  hunkIndex,
573
669
  lines: collapsedLines,
@@ -579,6 +675,14 @@ function pushSeparator(type, { hunkIndex, collapsedLines, rangeSize, hunkSpecs,
579
675
  } : void 0
580
676
  });
581
677
  }
678
+ function calculateTrailingRangeSize(fileDiff) {
679
+ const lastHunk = fileDiff.hunks.at(-1);
680
+ if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) return 0;
681
+ const additionRemaining = fileDiff.additionLines.length - (lastHunk.additionLineIndex + lastHunk.additionCount);
682
+ const deletionRemaining = fileDiff.deletionLines.length - (lastHunk.deletionLineIndex + lastHunk.deletionCount);
683
+ if (additionRemaining !== deletionRemaining) throw new Error(`DiffHunksRenderer.processDiffResult: trailing context mismatch (additions=${additionRemaining}, deletions=${deletionRemaining}) for ${fileDiff.name}`);
684
+ return Math.min(additionRemaining, deletionRemaining);
685
+ }
582
686
 
583
687
  //#endregion
584
688
  export { DiffHunksRenderer };