@pierre/diffs 1.1.20 → 1.2.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CodeView.d.ts +324 -0
- package/dist/components/CodeView.d.ts.map +1 -0
- package/dist/components/CodeView.js +1245 -0
- package/dist/components/CodeView.js.map +1 -0
- package/dist/components/File.d.ts +13 -12
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +68 -28
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +9 -10
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +57 -30
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.js +9 -3
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +28 -5
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +225 -45
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +28 -5
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +285 -49
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.d.ts +6 -3
- package/dist/components/Virtualizer.d.ts.map +1 -1
- package/dist/components/Virtualizer.js +4 -6
- package/dist/components/Virtualizer.js.map +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts +2 -2
- package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
- package/dist/constants.d.ts +6 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +17 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +11 -10
- package/dist/managers/InteractionManager.d.ts +11 -7
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +38 -25
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/ResizeManager.d.ts +4 -4
- package/dist/managers/ResizeManager.d.ts.map +1 -1
- package/dist/managers/ResizeManager.js +89 -54
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/managers/UniversalRenderingManager.d.ts +2 -1
- package/dist/managers/UniversalRenderingManager.d.ts.map +1 -1
- package/dist/managers/UniversalRenderingManager.js +13 -16
- package/dist/managers/UniversalRenderingManager.js.map +1 -1
- package/dist/react/CodeView.d.ts +45 -0
- package/dist/react/CodeView.d.ts.map +1 -0
- package/dist/react/CodeView.js +241 -0
- package/dist/react/CodeView.js.map +1 -0
- package/dist/react/File.d.ts +0 -1
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +2 -3
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +0 -1
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +3 -4
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +0 -1
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +3 -4
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +0 -1
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +3 -4
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +0 -1
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js +3 -4
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/constants.d.ts.map +1 -1
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +5 -4
- package/dist/react/types.d.ts +0 -8
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +0 -2
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +3 -4
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/renderFileChildren.d.ts +0 -2
- package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
- package/dist/react/utils/renderFileChildren.js +3 -4
- package/dist/react/utils/renderFileChildren.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +12 -7
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.js +12 -7
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +6 -2
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +2 -1
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +35 -20
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +2 -1
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +34 -20
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.js +1 -1
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +98 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.d.ts +7 -0
- package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -0
- package/dist/utils/areManagedSnapshotsEqual.js +15 -0
- package/dist/utils/areManagedSnapshotsEqual.js.map +1 -0
- package/dist/utils/areOptionsEqual.d.ts +2 -1
- package/dist/utils/areOptionsEqual.d.ts.map +1 -1
- package/dist/utils/areOptionsEqual.js +1 -1
- package/dist/utils/areOptionsEqual.js.map +1 -1
- package/dist/utils/createFileHeaderElement.d.ts +3 -1
- package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
- package/dist/utils/createFileHeaderElement.js +3 -2
- package/dist/utils/createFileHeaderElement.js.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.d.ts +3 -3
- package/dist/utils/createWindowFromScrollPosition.d.ts.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.js +6 -6
- package/dist/utils/createWindowFromScrollPosition.js.map +1 -1
- package/dist/utils/iterateOverDiff.d.ts +2 -1
- package/dist/utils/iterateOverDiff.d.ts.map +1 -1
- package/dist/utils/iterateOverDiff.js +135 -7
- package/dist/utils/iterateOverDiff.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +1 -1
- package/dist/utils/resolveVirtualFileMetrics.d.ts +4 -1
- package/dist/utils/resolveVirtualFileMetrics.d.ts.map +1 -1
- package/dist/utils/resolveVirtualFileMetrics.js +11 -1
- package/dist/utils/resolveVirtualFileMetrics.js.map +1 -1
- package/dist/utils/roundToDevicePixel.d.ts +14 -0
- package/dist/utils/roundToDevicePixel.d.ts.map +1 -0
- package/dist/utils/roundToDevicePixel.js +18 -0
- package/dist/utils/roundToDevicePixel.js.map +1 -0
- package/dist/worker/worker-portable.js +195 -14
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +146 -7
- package/dist/worker/worker.js.map +1 -1
- package/package.json +7 -1
- package/dist/components/AdvancedVirtualizedFileDiff.d.ts +0 -40
- package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +0 -1
- package/dist/components/AdvancedVirtualizedFileDiff.js +0 -140
- package/dist/components/AdvancedVirtualizedFileDiff.js.map +0 -1
- package/dist/components/AdvancedVirtualizer.d.ts +0 -38
- package/dist/components/AdvancedVirtualizer.d.ts.map +0 -1
- package/dist/components/AdvancedVirtualizer.js +0 -201
- package/dist/components/AdvancedVirtualizer.js.map +0 -1
|
@@ -9270,7 +9270,7 @@ function l(a$1) {
|
|
|
9270
9270
|
}
|
|
9271
9271
|
|
|
9272
9272
|
//#endregion
|
|
9273
|
-
//#region ../../node_modules/.bun/regex@6.0
|
|
9273
|
+
//#region ../../node_modules/.bun/regex@6.1.0/node_modules/regex/src/utils-internals.js
|
|
9274
9274
|
const noncapturingDelim = String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;
|
|
9275
9275
|
/**
|
|
9276
9276
|
Updates the array in place by incrementing each value greater than or equal to the threshold.
|
|
@@ -9458,13 +9458,16 @@ function getGroupContents(expression, contentsStartPos) {
|
|
|
9458
9458
|
}
|
|
9459
9459
|
|
|
9460
9460
|
//#endregion
|
|
9461
|
-
//#region ../../node_modules/.bun/regex@6.0
|
|
9461
|
+
//#region ../../node_modules/.bun/regex@6.1.0/node_modules/regex/src/atomic.js
|
|
9462
|
+
/**
|
|
9463
|
+
@import {PluginData, PluginResult} from './regex.js';
|
|
9464
|
+
*/
|
|
9462
9465
|
const atomicPluginToken = new RegExp(String.raw`(?<noncapturingStart>${noncapturingDelim})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`, "gsu");
|
|
9463
9466
|
/**
|
|
9464
9467
|
Apply transformations for atomic groups: `(?>…)`.
|
|
9465
9468
|
@param {string} expression
|
|
9466
|
-
@param {
|
|
9467
|
-
@returns {Required<
|
|
9469
|
+
@param {PluginData} [data]
|
|
9470
|
+
@returns {Required<PluginResult>}
|
|
9468
9471
|
*/
|
|
9469
9472
|
function atomic(expression, data) {
|
|
9470
9473
|
const hiddenCaptures = data?.hiddenCaptures ?? [];
|
|
@@ -9572,7 +9575,7 @@ Transform posessive quantifiers into atomic groups. The posessessive quantifiers
|
|
|
9572
9575
|
This follows Java, PCRE, Perl, and Python.
|
|
9573
9576
|
Possessive quantifiers in Oniguruma and Onigmo are only: `?+`, `*+`, `++`.
|
|
9574
9577
|
@param {string} expression
|
|
9575
|
-
@returns {
|
|
9578
|
+
@returns {PluginResult}
|
|
9576
9579
|
*/
|
|
9577
9580
|
function possessive(expression) {
|
|
9578
9581
|
if (!new RegExp(`${baseQuantifier}\\+`).test(expression)) {
|
|
@@ -9631,7 +9634,7 @@ function possessive(expression) {
|
|
|
9631
9634
|
}
|
|
9632
9635
|
|
|
9633
9636
|
//#endregion
|
|
9634
|
-
//#region ../../node_modules/.bun/regex@6.0
|
|
9637
|
+
//#region ../../node_modules/.bun/regex@6.1.0/node_modules/regex/src/subclass.js
|
|
9635
9638
|
/**
|
|
9636
9639
|
Works the same as JavaScript's native `RegExp` constructor in all contexts, but automatically
|
|
9637
9640
|
adjusts subpattern matches and indices (with flag `d`) to account for captures added as part of
|
|
@@ -12159,12 +12162,27 @@ const THEME_CSS_ATTRIBUTE = "data-theme-css";
|
|
|
12159
12162
|
const UNSAFE_CSS_ATTRIBUTE = "data-unsafe-css";
|
|
12160
12163
|
const CORE_CSS_ATTRIBUTE = "data-core-css";
|
|
12161
12164
|
const DEFAULT_COLLAPSED_CONTEXT_THRESHOLD = 1;
|
|
12165
|
+
const DEFAULT_TOKENIZE_MAX_LENGTH = 1e5;
|
|
12162
12166
|
const DEFAULT_VIRTUAL_FILE_METRICS = {
|
|
12163
12167
|
hunkLineCount: 50,
|
|
12164
12168
|
lineHeight: 20,
|
|
12165
12169
|
diffHeaderHeight: 44,
|
|
12166
12170
|
hunkSeparatorHeight: 32,
|
|
12167
|
-
|
|
12171
|
+
spacing: 8
|
|
12172
|
+
};
|
|
12173
|
+
const DEFAULT_CODE_VIEW_FILE_METRICS = {
|
|
12174
|
+
...DEFAULT_VIRTUAL_FILE_METRICS,
|
|
12175
|
+
hunkLineCount: 1
|
|
12176
|
+
};
|
|
12177
|
+
const DEFAULT_CODE_VIEW_METRICS = {
|
|
12178
|
+
paddingTop: 8,
|
|
12179
|
+
paddingBottom: 8,
|
|
12180
|
+
gap: 8
|
|
12181
|
+
};
|
|
12182
|
+
const DEFAULT_SMOOTH_SCROLL_SETTINGS = {
|
|
12183
|
+
omega: .015,
|
|
12184
|
+
positionEpsilon: .5,
|
|
12185
|
+
velocityEpsilon: .05
|
|
12168
12186
|
};
|
|
12169
12187
|
const DEFAULT_EXPANDED_REGION = Object.freeze({
|
|
12170
12188
|
fromStart: 0,
|
|
@@ -15069,13 +15087,20 @@ function getLineNodes(nodes) {
|
|
|
15069
15087
|
//#endregion
|
|
15070
15088
|
//#region src/utils/iterateOverDiff.ts
|
|
15071
15089
|
function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infinity, expandedHunks, collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, callback }) {
|
|
15090
|
+
const iterationStart = getIterationStartState({
|
|
15091
|
+
diff,
|
|
15092
|
+
diffStyle,
|
|
15093
|
+
startingLine,
|
|
15094
|
+
expandedHunks,
|
|
15095
|
+
collapsedContextThreshold
|
|
15096
|
+
});
|
|
15072
15097
|
const state = {
|
|
15073
15098
|
finalHunk: diff.hunks.at(-1),
|
|
15074
15099
|
viewportStart: startingLine,
|
|
15075
15100
|
viewportEnd: startingLine + totalLines,
|
|
15076
15101
|
isWindowedHighlight: startingLine > 0 || totalLines < Infinity,
|
|
15077
|
-
splitCount:
|
|
15078
|
-
unifiedCount:
|
|
15102
|
+
splitCount: iterationStart.splitCount,
|
|
15103
|
+
unifiedCount: iterationStart.unifiedCount,
|
|
15079
15104
|
shouldBreak() {
|
|
15080
15105
|
if (!state.isWindowedHighlight) {
|
|
15081
15106
|
return false;
|
|
@@ -15145,7 +15170,11 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15145
15170
|
return callback(props) ?? false;
|
|
15146
15171
|
}
|
|
15147
15172
|
};
|
|
15148
|
-
hunkIterator: for (
|
|
15173
|
+
hunkIterator: for (let hunkIndex = iterationStart.hunkIndex; hunkIndex < diff.hunks.length; hunkIndex++) {
|
|
15174
|
+
const hunk = diff.hunks[hunkIndex];
|
|
15175
|
+
if (hunk == null) {
|
|
15176
|
+
throw new Error("iterateOverDiff: invalid hunk index");
|
|
15177
|
+
}
|
|
15149
15178
|
if (state.shouldBreak()) {
|
|
15150
15179
|
break;
|
|
15151
15180
|
}
|
|
@@ -15187,8 +15216,16 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15187
15216
|
let additionLineIndex$1 = hunk.additionLineIndex - leadingRegion.rangeSize;
|
|
15188
15217
|
let deletionLineNumber$1 = hunk.deletionStart - leadingRegion.rangeSize;
|
|
15189
15218
|
let additionLineNumber$1 = hunk.additionStart - leadingRegion.rangeSize;
|
|
15190
|
-
|
|
15219
|
+
const [startIndex, endIndex] = getEqualLineIterationRange(state, leadingRegion.fromStart, diffStyle);
|
|
15220
|
+
if (startIndex > 0) {
|
|
15221
|
+
state.incrementCounts(startIndex, startIndex);
|
|
15222
|
+
}
|
|
15223
|
+
let index = startIndex;
|
|
15191
15224
|
while (index < leadingRegion.fromStart) {
|
|
15225
|
+
if (index >= endIndex) {
|
|
15226
|
+
state.incrementCounts(leadingRegion.fromStart - index, leadingRegion.fromStart - index);
|
|
15227
|
+
break;
|
|
15228
|
+
}
|
|
15192
15229
|
if (state.isInWindow(0, 0)) {
|
|
15193
15230
|
if (state.emit({
|
|
15194
15231
|
hunkIndex,
|
|
@@ -15224,8 +15261,16 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15224
15261
|
additionLineIndex$1 = hunk.additionLineIndex - leadingRegion.fromEnd;
|
|
15225
15262
|
deletionLineNumber$1 = hunk.deletionStart - leadingRegion.fromEnd;
|
|
15226
15263
|
additionLineNumber$1 = hunk.additionStart - leadingRegion.fromEnd;
|
|
15227
|
-
|
|
15264
|
+
const [fromEndStartIndex, fromEndEndIndex] = getEqualLineIterationRange(state, leadingRegion.fromEnd, diffStyle);
|
|
15265
|
+
if (fromEndStartIndex > 0) {
|
|
15266
|
+
state.incrementCounts(fromEndStartIndex, fromEndStartIndex);
|
|
15267
|
+
}
|
|
15268
|
+
index = fromEndStartIndex;
|
|
15228
15269
|
while (index < leadingRegion.fromEnd) {
|
|
15270
|
+
if (index >= fromEndEndIndex) {
|
|
15271
|
+
state.incrementCounts(leadingRegion.fromEnd - index, leadingRegion.fromEnd - index);
|
|
15272
|
+
break;
|
|
15273
|
+
}
|
|
15229
15274
|
if (state.isInWindow(0, 0)) {
|
|
15230
15275
|
if (state.emit({
|
|
15231
15276
|
hunkIndex,
|
|
@@ -15273,8 +15318,16 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15273
15318
|
const isLastContent = content === lastContent;
|
|
15274
15319
|
if (content.type === "context") {
|
|
15275
15320
|
if (!state.shouldSkip(content.lines, content.lines)) {
|
|
15276
|
-
|
|
15321
|
+
const [startIndex, endIndex] = getEqualLineIterationRange(state, content.lines, diffStyle);
|
|
15322
|
+
if (startIndex > 0) {
|
|
15323
|
+
state.incrementCounts(startIndex, startIndex);
|
|
15324
|
+
}
|
|
15325
|
+
let index = startIndex;
|
|
15277
15326
|
while (index < content.lines) {
|
|
15327
|
+
if (index >= endIndex) {
|
|
15328
|
+
state.incrementCounts(content.lines - index, content.lines - index);
|
|
15329
|
+
break;
|
|
15330
|
+
}
|
|
15278
15331
|
if (state.isInWindow(0, 0)) {
|
|
15279
15332
|
const isLastLine = isLastContent && index === content.lines - 1;
|
|
15280
15333
|
const unifiedRowIndex = unifiedLineIndex + index;
|
|
@@ -15364,11 +15417,19 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15364
15417
|
if (trailingRegion != null) {
|
|
15365
15418
|
const { collapsedLines, fromStart, fromEnd } = trailingRegion;
|
|
15366
15419
|
const len = fromStart + fromEnd;
|
|
15367
|
-
|
|
15420
|
+
const [startIndex, endIndex] = getEqualLineIterationRange(state, len, diffStyle);
|
|
15421
|
+
if (startIndex > 0) {
|
|
15422
|
+
state.incrementCounts(startIndex, startIndex);
|
|
15423
|
+
}
|
|
15424
|
+
let index = startIndex;
|
|
15368
15425
|
while (index < len) {
|
|
15369
15426
|
if (state.shouldBreak()) {
|
|
15370
15427
|
break hunkIterator;
|
|
15371
15428
|
}
|
|
15429
|
+
if (index >= endIndex) {
|
|
15430
|
+
state.incrementCounts(len - index, len - index);
|
|
15431
|
+
break;
|
|
15432
|
+
}
|
|
15372
15433
|
if (state.isInWindow(0, 0)) {
|
|
15373
15434
|
const isLastLine = index === len - 1;
|
|
15374
15435
|
if (state.emit({
|
|
@@ -15402,6 +15463,126 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15402
15463
|
}
|
|
15403
15464
|
}
|
|
15404
15465
|
}
|
|
15466
|
+
function getIterationStartState({ diff, diffStyle, startingLine, expandedHunks, collapsedContextThreshold }) {
|
|
15467
|
+
if (startingLine <= 0 || diffStyle === "both") {
|
|
15468
|
+
return {
|
|
15469
|
+
hunkIndex: 0,
|
|
15470
|
+
splitCount: 0,
|
|
15471
|
+
unifiedCount: 0
|
|
15472
|
+
};
|
|
15473
|
+
}
|
|
15474
|
+
const prefixCounts = getHunkPrefixCounts({
|
|
15475
|
+
diff,
|
|
15476
|
+
expandedHunks,
|
|
15477
|
+
collapsedContextThreshold
|
|
15478
|
+
});
|
|
15479
|
+
let low = 0;
|
|
15480
|
+
let high = diff.hunks.length - 1;
|
|
15481
|
+
let result = diff.hunks.length;
|
|
15482
|
+
while (low <= high) {
|
|
15483
|
+
const mid = low + high >> 1;
|
|
15484
|
+
const counts$1 = prefixCounts[mid + 1];
|
|
15485
|
+
if (counts$1 == null) {
|
|
15486
|
+
throw new Error("iterateOverDiff: invalid hunk prefix index");
|
|
15487
|
+
}
|
|
15488
|
+
const selectedCount = diffStyle === "unified" ? counts$1.unifiedCount : counts$1.splitCount;
|
|
15489
|
+
if (selectedCount > startingLine) {
|
|
15490
|
+
result = mid;
|
|
15491
|
+
high = mid - 1;
|
|
15492
|
+
} else {
|
|
15493
|
+
low = mid + 1;
|
|
15494
|
+
}
|
|
15495
|
+
}
|
|
15496
|
+
if (result >= diff.hunks.length) {
|
|
15497
|
+
const counts$1 = prefixCounts[diff.hunks.length];
|
|
15498
|
+
if (counts$1 == null) {
|
|
15499
|
+
throw new Error("iterateOverDiff: invalid terminal hunk prefix index");
|
|
15500
|
+
}
|
|
15501
|
+
return {
|
|
15502
|
+
hunkIndex: diff.hunks.length,
|
|
15503
|
+
splitCount: counts$1.splitCount,
|
|
15504
|
+
unifiedCount: counts$1.unifiedCount
|
|
15505
|
+
};
|
|
15506
|
+
}
|
|
15507
|
+
const counts = prefixCounts[result];
|
|
15508
|
+
if (counts == null) {
|
|
15509
|
+
throw new Error("iterateOverDiff: invalid selected hunk prefix index");
|
|
15510
|
+
}
|
|
15511
|
+
return {
|
|
15512
|
+
hunkIndex: result,
|
|
15513
|
+
splitCount: counts.splitCount,
|
|
15514
|
+
unifiedCount: counts.unifiedCount
|
|
15515
|
+
};
|
|
15516
|
+
}
|
|
15517
|
+
function getHunkPrefixCounts({ diff, expandedHunks, collapsedContextThreshold }) {
|
|
15518
|
+
let splitCount = 0;
|
|
15519
|
+
let unifiedCount = 0;
|
|
15520
|
+
const finalHunkIndex = diff.hunks.length - 1;
|
|
15521
|
+
const prefixCounts = [{
|
|
15522
|
+
splitCount: 0,
|
|
15523
|
+
unifiedCount: 0
|
|
15524
|
+
}];
|
|
15525
|
+
for (let index = 0; index < diff.hunks.length; index++) {
|
|
15526
|
+
const hunk = diff.hunks[index];
|
|
15527
|
+
if (hunk == null) {
|
|
15528
|
+
throw new Error("iterateOverDiff: invalid hunk summary index");
|
|
15529
|
+
}
|
|
15530
|
+
const leadingRegion = getExpandedRegion(diff.isPartial, hunk.collapsedBefore, expandedHunks, index, collapsedContextThreshold);
|
|
15531
|
+
const leadingCount = leadingRegion.fromStart + leadingRegion.fromEnd;
|
|
15532
|
+
splitCount += leadingCount + hunk.splitLineCount;
|
|
15533
|
+
unifiedCount += leadingCount + hunk.unifiedLineCount;
|
|
15534
|
+
if (index === finalHunkIndex && hasFinalCollapsedHunk(diff)) {
|
|
15535
|
+
const trailingRangeSize = getTrailingRangeSize(diff, hunk);
|
|
15536
|
+
const trailingRegion = getExpandedRegion(diff.isPartial, trailingRangeSize, expandedHunks, diff.hunks.length, collapsedContextThreshold);
|
|
15537
|
+
const trailingCount = trailingRegion.fromStart + trailingRegion.fromEnd;
|
|
15538
|
+
splitCount += trailingCount;
|
|
15539
|
+
unifiedCount += trailingCount;
|
|
15540
|
+
}
|
|
15541
|
+
prefixCounts.push({
|
|
15542
|
+
splitCount,
|
|
15543
|
+
unifiedCount
|
|
15544
|
+
});
|
|
15545
|
+
}
|
|
15546
|
+
return prefixCounts;
|
|
15547
|
+
}
|
|
15548
|
+
function getEqualLineIterationRange(state, count, diffStyle) {
|
|
15549
|
+
if (!state.isWindowedHighlight || count <= 0) {
|
|
15550
|
+
return [0, count];
|
|
15551
|
+
}
|
|
15552
|
+
const ranges = [];
|
|
15553
|
+
function pushRange(currentCount) {
|
|
15554
|
+
const start$1 = Math.max(0, state.viewportStart - currentCount);
|
|
15555
|
+
const end$1 = Math.min(count, state.viewportEnd - currentCount);
|
|
15556
|
+
if (end$1 > start$1) {
|
|
15557
|
+
ranges.push([start$1, end$1]);
|
|
15558
|
+
}
|
|
15559
|
+
}
|
|
15560
|
+
if (diffStyle !== "split") {
|
|
15561
|
+
pushRange(state.unifiedCount);
|
|
15562
|
+
}
|
|
15563
|
+
if (diffStyle !== "unified") {
|
|
15564
|
+
pushRange(state.splitCount);
|
|
15565
|
+
}
|
|
15566
|
+
if (ranges.length === 0) {
|
|
15567
|
+
return [0, 0];
|
|
15568
|
+
}
|
|
15569
|
+
let start = ranges[0][0];
|
|
15570
|
+
let end = ranges[0][1];
|
|
15571
|
+
for (let index = 1; index < ranges.length; index++) {
|
|
15572
|
+
const range$1 = ranges[index];
|
|
15573
|
+
start = Math.min(start, range$1[0]);
|
|
15574
|
+
end = Math.max(end, range$1[1]);
|
|
15575
|
+
}
|
|
15576
|
+
return [start, end];
|
|
15577
|
+
}
|
|
15578
|
+
function getTrailingRangeSize(diff, hunk) {
|
|
15579
|
+
const additionRemaining = diff.additionLines.length - (hunk.additionLineIndex + hunk.additionCount);
|
|
15580
|
+
const deletionRemaining = diff.deletionLines.length - (hunk.deletionLineIndex + hunk.deletionCount);
|
|
15581
|
+
if (additionRemaining !== deletionRemaining) {
|
|
15582
|
+
throw new Error(`iterateOverDiff: trailing context mismatch (additions=${additionRemaining}, deletions=${deletionRemaining}) for ${diff.name}`);
|
|
15583
|
+
}
|
|
15584
|
+
return Math.min(additionRemaining, deletionRemaining);
|
|
15585
|
+
}
|
|
15405
15586
|
function getExpandedRegion(isPartial, rangeSize, expandedHunks, hunkIndex, collapsedContextThreshold) {
|
|
15406
15587
|
rangeSize = Math.max(rangeSize, 0);
|
|
15407
15588
|
if (rangeSize === 0 || isPartial) {
|