@pierre/diffs 1.2.4 → 1.2.6
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 +1 -0
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +23 -0
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +6 -1
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +22 -42
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.js +5 -3
- package/dist/components/Virtualizer.js.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +5 -9
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/utils/computeEstimatedDiffHeights.js +9 -20
- package/dist/utils/computeEstimatedDiffHeights.js.map +1 -1
- package/dist/utils/iterateOverDiff.js +147 -182
- package/dist/utils/iterateOverDiff.js.map +1 -1
- package/dist/utils/virtualDiffLayout.d.ts +23 -2
- package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
- package/dist/utils/virtualDiffLayout.js +41 -1
- package/dist/utils/virtualDiffLayout.js.map +1 -1
- package/dist/worker/worker-portable.js +207 -205
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +179 -181
- package/dist/worker/worker.js.map +1 -1
- package/package.json +20 -20
|
@@ -15168,6 +15168,60 @@ function getExpandedRegion({ isPartial, rangeSize, expandedHunks, hunkIndex, col
|
|
|
15168
15168
|
renderAll
|
|
15169
15169
|
};
|
|
15170
15170
|
}
|
|
15171
|
+
function hasTrailingContext(fileDiff) {
|
|
15172
|
+
const lastHunk = fileDiff.hunks[fileDiff.hunks.length - 1];
|
|
15173
|
+
if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) {
|
|
15174
|
+
return false;
|
|
15175
|
+
}
|
|
15176
|
+
const additionRemaining = fileDiff.additionLines.length - (lastHunk.additionLineIndex + lastHunk.additionCount);
|
|
15177
|
+
const deletionRemaining = fileDiff.deletionLines.length - (lastHunk.deletionLineIndex + lastHunk.deletionCount);
|
|
15178
|
+
return additionRemaining > 0 || deletionRemaining > 0;
|
|
15179
|
+
}
|
|
15180
|
+
function getTrailingContextRangeSize({ fileDiff, errorPrefix }) {
|
|
15181
|
+
const lastHunk = fileDiff.hunks[fileDiff.hunks.length - 1];
|
|
15182
|
+
if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) {
|
|
15183
|
+
return 0;
|
|
15184
|
+
}
|
|
15185
|
+
const additionRemaining = fileDiff.additionLines.length - (lastHunk.additionLineIndex + lastHunk.additionCount);
|
|
15186
|
+
const deletionRemaining = fileDiff.deletionLines.length - (lastHunk.deletionLineIndex + lastHunk.deletionCount);
|
|
15187
|
+
if (additionRemaining <= 0 && deletionRemaining <= 0) {
|
|
15188
|
+
return 0;
|
|
15189
|
+
}
|
|
15190
|
+
if (additionRemaining !== deletionRemaining) {
|
|
15191
|
+
throw new Error(`${errorPrefix}: trailing context mismatch (additions=${additionRemaining}, deletions=${deletionRemaining}) for ${fileDiff.name}`);
|
|
15192
|
+
}
|
|
15193
|
+
return Math.min(additionRemaining, deletionRemaining);
|
|
15194
|
+
}
|
|
15195
|
+
function getTrailingExpandedRegion({ fileDiff, hunkIndex, expandedHunks, collapsedContextThreshold, errorPrefix }) {
|
|
15196
|
+
if (hunkIndex !== fileDiff.hunks.length - 1) {
|
|
15197
|
+
return undefined;
|
|
15198
|
+
}
|
|
15199
|
+
const trailingRangeSize = getTrailingContextRangeSize({
|
|
15200
|
+
fileDiff,
|
|
15201
|
+
errorPrefix
|
|
15202
|
+
});
|
|
15203
|
+
if (trailingRangeSize <= 0) {
|
|
15204
|
+
return undefined;
|
|
15205
|
+
}
|
|
15206
|
+
if (expandedHunks === true || trailingRangeSize <= collapsedContextThreshold) {
|
|
15207
|
+
return {
|
|
15208
|
+
fromStart: trailingRangeSize,
|
|
15209
|
+
fromEnd: 0,
|
|
15210
|
+
rangeSize: trailingRangeSize,
|
|
15211
|
+
collapsedLines: 0,
|
|
15212
|
+
renderAll: true
|
|
15213
|
+
};
|
|
15214
|
+
}
|
|
15215
|
+
const region = expandedHunks?.get(fileDiff.hunks.length);
|
|
15216
|
+
const fromStart = Math.min(Math.max(region?.fromStart ?? 0, 0), trailingRangeSize);
|
|
15217
|
+
return {
|
|
15218
|
+
fromStart,
|
|
15219
|
+
fromEnd: 0,
|
|
15220
|
+
rangeSize: trailingRangeSize,
|
|
15221
|
+
collapsedLines: trailingRangeSize - fromStart,
|
|
15222
|
+
renderAll: fromStart >= trailingRangeSize
|
|
15223
|
+
};
|
|
15224
|
+
}
|
|
15171
15225
|
function getHunkSeparatorHeight({ type, metrics }) {
|
|
15172
15226
|
return metrics.hunkSeparatorHeight ?? getDefaultHunkSeparatorHeight(type);
|
|
15173
15227
|
}
|
|
@@ -15242,12 +15296,12 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15242
15296
|
collapsedContextThreshold
|
|
15243
15297
|
});
|
|
15244
15298
|
const state = {
|
|
15245
|
-
finalHunk: diff.hunks.at(-1),
|
|
15246
15299
|
viewportStart: startingLine,
|
|
15247
15300
|
viewportEnd: startingLine + totalLines,
|
|
15248
15301
|
isWindowedHighlight: startingLine > 0 || totalLines < Infinity,
|
|
15249
15302
|
splitCount: iterationStart.splitCount,
|
|
15250
15303
|
unifiedCount: iterationStart.unifiedCount,
|
|
15304
|
+
finalHunkIndex: diff.hunks.length - 1,
|
|
15251
15305
|
shouldBreak() {
|
|
15252
15306
|
if (!state.isWindowedHighlight) {
|
|
15253
15307
|
return false;
|
|
@@ -15332,24 +15386,13 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15332
15386
|
hunkIndex,
|
|
15333
15387
|
collapsedContextThreshold
|
|
15334
15388
|
});
|
|
15335
|
-
const trailingRegion =
|
|
15336
|
-
|
|
15337
|
-
|
|
15338
|
-
|
|
15339
|
-
|
|
15340
|
-
|
|
15341
|
-
|
|
15342
|
-
throw new Error(`iterateOverDiff: trailing context mismatch (additions=${additionRemaining}, deletions=${deletionRemaining}) for ${diff.name}`);
|
|
15343
|
-
}
|
|
15344
|
-
const trailingRangeSize = Math.min(additionRemaining, deletionRemaining);
|
|
15345
|
-
return getExpandedRegion({
|
|
15346
|
-
isPartial: diff.isPartial,
|
|
15347
|
-
rangeSize: trailingRangeSize,
|
|
15348
|
-
expandedHunks,
|
|
15349
|
-
hunkIndex: diff.hunks.length,
|
|
15350
|
-
collapsedContextThreshold
|
|
15351
|
-
});
|
|
15352
|
-
})();
|
|
15389
|
+
const trailingRegion = hunkIndex === state.finalHunkIndex ? getTrailingExpandedRegion({
|
|
15390
|
+
fileDiff: diff,
|
|
15391
|
+
hunkIndex,
|
|
15392
|
+
expandedHunks,
|
|
15393
|
+
collapsedContextThreshold,
|
|
15394
|
+
errorPrefix: "iterateOverDiff"
|
|
15395
|
+
}) : undefined;
|
|
15353
15396
|
const expandedLineCount = leadingRegion.fromStart + leadingRegion.fromEnd;
|
|
15354
15397
|
function getTrailingCollapsedAfter(unifiedLineIndex$1, splitLineIndex$1) {
|
|
15355
15398
|
if (trailingRegion == null || trailingRegion.collapsedLines <= 0 || trailingRegion.fromStart + trailingRegion.fromEnd > 0) {
|
|
@@ -15360,13 +15403,13 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15360
15403
|
}
|
|
15361
15404
|
return splitLineIndex$1 === hunk.splitLineStart + hunk.splitLineCount - 1 ? trailingRegion.collapsedLines : 0;
|
|
15362
15405
|
}
|
|
15363
|
-
|
|
15364
|
-
|
|
15406
|
+
let consumedCollapsed = leadingRegion.collapsedLines === 0;
|
|
15407
|
+
function consumePendingCollapsed() {
|
|
15408
|
+
if (consumedCollapsed) {
|
|
15365
15409
|
return 0;
|
|
15366
15410
|
}
|
|
15367
|
-
|
|
15368
|
-
leadingRegion.collapsedLines
|
|
15369
|
-
return value;
|
|
15411
|
+
consumedCollapsed = true;
|
|
15412
|
+
return leadingRegion.collapsedLines;
|
|
15370
15413
|
}
|
|
15371
15414
|
if (!state.shouldSkip(expandedLineCount, expandedLineCount)) {
|
|
15372
15415
|
let unifiedLineIndex$1 = hunk.unifiedLineStart - leadingRegion.rangeSize;
|
|
@@ -15375,44 +15418,30 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15375
15418
|
let additionLineIndex$1 = hunk.additionLineIndex - leadingRegion.rangeSize;
|
|
15376
15419
|
let deletionLineNumber$1 = hunk.deletionStart - leadingRegion.rangeSize;
|
|
15377
15420
|
let additionLineNumber$1 = hunk.additionStart - leadingRegion.rangeSize;
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
|
|
15383
|
-
|
|
15384
|
-
|
|
15385
|
-
|
|
15386
|
-
|
|
15387
|
-
|
|
15388
|
-
|
|
15389
|
-
|
|
15390
|
-
|
|
15391
|
-
|
|
15392
|
-
|
|
15393
|
-
|
|
15394
|
-
|
|
15395
|
-
|
|
15396
|
-
|
|
15397
|
-
|
|
15398
|
-
noEOFCR: false,
|
|
15399
|
-
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
15400
|
-
splitLineIndex: splitLineIndex$1 + index
|
|
15401
|
-
},
|
|
15402
|
-
additionLine: {
|
|
15403
|
-
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
15404
|
-
splitLineIndex: splitLineIndex$1 + index,
|
|
15405
|
-
lineIndex: additionLineIndex$1 + index,
|
|
15406
|
-
lineNumber: additionLineNumber$1 + index,
|
|
15407
|
-
noEOFCR: false
|
|
15408
|
-
}
|
|
15409
|
-
})) {
|
|
15410
|
-
break hunkIterator;
|
|
15421
|
+
if (walkContextLines(state, leadingRegion.fromStart, diffStyle, (index) => {
|
|
15422
|
+
return state.emit({
|
|
15423
|
+
hunkIndex,
|
|
15424
|
+
hunk,
|
|
15425
|
+
collapsedBefore: 0,
|
|
15426
|
+
collapsedAfter: 0,
|
|
15427
|
+
type: "context-expanded",
|
|
15428
|
+
deletionLine: {
|
|
15429
|
+
lineNumber: deletionLineNumber$1 + index,
|
|
15430
|
+
lineIndex: deletionLineIndex$1 + index,
|
|
15431
|
+
noEOFCR: false,
|
|
15432
|
+
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
15433
|
+
splitLineIndex: splitLineIndex$1 + index
|
|
15434
|
+
},
|
|
15435
|
+
additionLine: {
|
|
15436
|
+
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
15437
|
+
splitLineIndex: splitLineIndex$1 + index,
|
|
15438
|
+
lineIndex: additionLineIndex$1 + index,
|
|
15439
|
+
lineNumber: additionLineNumber$1 + index,
|
|
15440
|
+
noEOFCR: false
|
|
15411
15441
|
}
|
|
15412
|
-
}
|
|
15413
|
-
|
|
15414
|
-
|
|
15415
|
-
index++;
|
|
15442
|
+
});
|
|
15443
|
+
})) {
|
|
15444
|
+
break hunkIterator;
|
|
15416
15445
|
}
|
|
15417
15446
|
unifiedLineIndex$1 = hunk.unifiedLineStart - leadingRegion.fromEnd;
|
|
15418
15447
|
splitLineIndex$1 = hunk.splitLineStart - leadingRegion.fromEnd;
|
|
@@ -15420,48 +15449,36 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15420
15449
|
additionLineIndex$1 = hunk.additionLineIndex - leadingRegion.fromEnd;
|
|
15421
15450
|
deletionLineNumber$1 = hunk.deletionStart - leadingRegion.fromEnd;
|
|
15422
15451
|
additionLineNumber$1 = hunk.additionStart - leadingRegion.fromEnd;
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
|
|
15426
|
-
|
|
15427
|
-
|
|
15428
|
-
|
|
15429
|
-
|
|
15430
|
-
|
|
15431
|
-
|
|
15432
|
-
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15443
|
-
noEOFCR: false,
|
|
15444
|
-
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
15445
|
-
splitLineIndex: splitLineIndex$1 + index
|
|
15446
|
-
},
|
|
15447
|
-
additionLine: {
|
|
15448
|
-
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
15449
|
-
splitLineIndex: splitLineIndex$1 + index,
|
|
15450
|
-
lineIndex: additionLineIndex$1 + index,
|
|
15451
|
-
lineNumber: additionLineNumber$1 + index,
|
|
15452
|
-
noEOFCR: false
|
|
15453
|
-
}
|
|
15454
|
-
})) {
|
|
15455
|
-
break hunkIterator;
|
|
15452
|
+
if (walkContextLines(state, leadingRegion.fromEnd, diffStyle, (index) => {
|
|
15453
|
+
return state.emit({
|
|
15454
|
+
hunkIndex,
|
|
15455
|
+
hunk,
|
|
15456
|
+
collapsedBefore: consumePendingCollapsed(),
|
|
15457
|
+
collapsedAfter: 0,
|
|
15458
|
+
type: "context-expanded",
|
|
15459
|
+
deletionLine: {
|
|
15460
|
+
lineNumber: deletionLineNumber$1 + index,
|
|
15461
|
+
lineIndex: deletionLineIndex$1 + index,
|
|
15462
|
+
noEOFCR: false,
|
|
15463
|
+
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
15464
|
+
splitLineIndex: splitLineIndex$1 + index
|
|
15465
|
+
},
|
|
15466
|
+
additionLine: {
|
|
15467
|
+
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
15468
|
+
splitLineIndex: splitLineIndex$1 + index,
|
|
15469
|
+
lineIndex: additionLineIndex$1 + index,
|
|
15470
|
+
lineNumber: additionLineNumber$1 + index,
|
|
15471
|
+
noEOFCR: false
|
|
15456
15472
|
}
|
|
15457
|
-
}
|
|
15458
|
-
|
|
15459
|
-
|
|
15460
|
-
|
|
15473
|
+
});
|
|
15474
|
+
}, () => {
|
|
15475
|
+
consumePendingCollapsed();
|
|
15476
|
+
})) {
|
|
15477
|
+
break hunkIterator;
|
|
15461
15478
|
}
|
|
15462
15479
|
} else {
|
|
15463
15480
|
state.incrementCounts(expandedLineCount, expandedLineCount);
|
|
15464
|
-
|
|
15481
|
+
consumePendingCollapsed();
|
|
15465
15482
|
}
|
|
15466
15483
|
let unifiedLineIndex = hunk.unifiedLineStart;
|
|
15467
15484
|
let splitLineIndex = hunk.splitLineStart;
|
|
@@ -15477,51 +15494,39 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15477
15494
|
const isLastContent = content === lastContent;
|
|
15478
15495
|
if (content.type === "context") {
|
|
15479
15496
|
if (!state.shouldSkip(content.lines, content.lines)) {
|
|
15480
|
-
|
|
15481
|
-
|
|
15482
|
-
|
|
15483
|
-
|
|
15484
|
-
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
|
|
15488
|
-
|
|
15489
|
-
|
|
15490
|
-
|
|
15491
|
-
|
|
15492
|
-
|
|
15493
|
-
|
|
15494
|
-
|
|
15495
|
-
|
|
15496
|
-
|
|
15497
|
-
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
|
|
15501
|
-
|
|
15502
|
-
|
|
15503
|
-
noEOFCR: isLastLine && hunk.noEOFCRDeletions,
|
|
15504
|
-
unifiedLineIndex: unifiedRowIndex,
|
|
15505
|
-
splitLineIndex: splitRowIndex
|
|
15506
|
-
},
|
|
15507
|
-
additionLine: {
|
|
15508
|
-
unifiedLineIndex: unifiedRowIndex,
|
|
15509
|
-
splitLineIndex: splitRowIndex,
|
|
15510
|
-
lineIndex: additionLineIndex + index,
|
|
15511
|
-
lineNumber: additionLineNumber + index,
|
|
15512
|
-
noEOFCR: isLastLine && hunk.noEOFCRAdditions
|
|
15513
|
-
}
|
|
15514
|
-
})) {
|
|
15515
|
-
break hunkIterator;
|
|
15497
|
+
if (walkContextLines(state, content.lines, diffStyle, (index) => {
|
|
15498
|
+
const isLastLine = isLastContent && index === content.lines - 1;
|
|
15499
|
+
const unifiedRowIndex = unifiedLineIndex + index;
|
|
15500
|
+
const splitRowIndex = splitLineIndex + index;
|
|
15501
|
+
return state.emit({
|
|
15502
|
+
hunkIndex,
|
|
15503
|
+
hunk,
|
|
15504
|
+
collapsedBefore: consumePendingCollapsed(),
|
|
15505
|
+
collapsedAfter: getTrailingCollapsedAfter(unifiedRowIndex, splitRowIndex),
|
|
15506
|
+
type: "context",
|
|
15507
|
+
deletionLine: {
|
|
15508
|
+
lineNumber: deletionLineNumber + index,
|
|
15509
|
+
lineIndex: deletionLineIndex + index,
|
|
15510
|
+
noEOFCR: isLastLine && hunk.noEOFCRDeletions,
|
|
15511
|
+
unifiedLineIndex: unifiedRowIndex,
|
|
15512
|
+
splitLineIndex: splitRowIndex
|
|
15513
|
+
},
|
|
15514
|
+
additionLine: {
|
|
15515
|
+
unifiedLineIndex: unifiedRowIndex,
|
|
15516
|
+
splitLineIndex: splitRowIndex,
|
|
15517
|
+
lineIndex: additionLineIndex + index,
|
|
15518
|
+
lineNumber: additionLineNumber + index,
|
|
15519
|
+
noEOFCR: isLastLine && hunk.noEOFCRAdditions
|
|
15516
15520
|
}
|
|
15517
|
-
}
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
|
|
15521
|
+
});
|
|
15522
|
+
}, () => {
|
|
15523
|
+
consumePendingCollapsed();
|
|
15524
|
+
})) {
|
|
15525
|
+
break hunkIterator;
|
|
15521
15526
|
}
|
|
15522
15527
|
} else {
|
|
15523
15528
|
state.incrementCounts(content.lines, content.lines);
|
|
15524
|
-
|
|
15529
|
+
consumePendingCollapsed();
|
|
15525
15530
|
}
|
|
15526
15531
|
unifiedLineIndex += content.lines;
|
|
15527
15532
|
splitLineIndex += content.lines;
|
|
@@ -15535,6 +15540,10 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15535
15540
|
const shouldSkipChange = state.shouldSkip(unifiedCount, splitCount);
|
|
15536
15541
|
if (!shouldSkipChange) {
|
|
15537
15542
|
const iterationRanges = getChangeIterationRanges(state, content, diffStyle);
|
|
15543
|
+
const firstRangeStart = iterationRanges[0]?.[0] ?? 0;
|
|
15544
|
+
if (firstRangeStart > 0) {
|
|
15545
|
+
consumePendingCollapsed();
|
|
15546
|
+
}
|
|
15538
15547
|
for (const [rangeStart, rangeEnd] of iterationRanges) {
|
|
15539
15548
|
for (let index = rangeStart; index < rangeEnd; index++) {
|
|
15540
15549
|
const unifiedRowIndex = unifiedLineIndex + index;
|
|
@@ -15543,7 +15552,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15543
15552
|
if (state.emit(getChangeLineData({
|
|
15544
15553
|
hunkIndex,
|
|
15545
15554
|
hunk,
|
|
15546
|
-
collapsedBefore:
|
|
15555
|
+
collapsedBefore: consumePendingCollapsed(),
|
|
15547
15556
|
collapsedAfter,
|
|
15548
15557
|
diffStyle,
|
|
15549
15558
|
index,
|
|
@@ -15563,7 +15572,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15563
15572
|
}
|
|
15564
15573
|
}
|
|
15565
15574
|
}
|
|
15566
|
-
|
|
15575
|
+
consumePendingCollapsed();
|
|
15567
15576
|
state.incrementCounts(unifiedCount, splitCount);
|
|
15568
15577
|
unifiedLineIndex += unifiedCount;
|
|
15569
15578
|
splitLineIndex += splitCount;
|
|
@@ -15576,48 +15585,31 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
15576
15585
|
if (trailingRegion != null) {
|
|
15577
15586
|
const { collapsedLines, fromStart, fromEnd } = trailingRegion;
|
|
15578
15587
|
const len = fromStart + fromEnd;
|
|
15579
|
-
|
|
15580
|
-
|
|
15581
|
-
state.
|
|
15582
|
-
|
|
15583
|
-
|
|
15584
|
-
|
|
15585
|
-
|
|
15586
|
-
|
|
15587
|
-
|
|
15588
|
-
|
|
15589
|
-
|
|
15590
|
-
|
|
15591
|
-
|
|
15592
|
-
|
|
15593
|
-
|
|
15594
|
-
|
|
15595
|
-
|
|
15596
|
-
|
|
15597
|
-
|
|
15598
|
-
|
|
15599
|
-
|
|
15600
|
-
deletionLine: {
|
|
15601
|
-
lineNumber: deletionLineNumber + index,
|
|
15602
|
-
lineIndex: deletionLineIndex + index,
|
|
15603
|
-
noEOFCR: false,
|
|
15604
|
-
unifiedLineIndex: unifiedLineIndex + index,
|
|
15605
|
-
splitLineIndex: splitLineIndex + index
|
|
15606
|
-
},
|
|
15607
|
-
additionLine: {
|
|
15608
|
-
unifiedLineIndex: unifiedLineIndex + index,
|
|
15609
|
-
splitLineIndex: splitLineIndex + index,
|
|
15610
|
-
lineIndex: additionLineIndex + index,
|
|
15611
|
-
lineNumber: additionLineNumber + index,
|
|
15612
|
-
noEOFCR: false
|
|
15613
|
-
}
|
|
15614
|
-
})) {
|
|
15615
|
-
break hunkIterator;
|
|
15588
|
+
if (walkContextLines(state, len, diffStyle, (index) => {
|
|
15589
|
+
const isLastLine = index === len - 1;
|
|
15590
|
+
return state.emit({
|
|
15591
|
+
hunkIndex: diff.hunks.length,
|
|
15592
|
+
hunk: undefined,
|
|
15593
|
+
collapsedBefore: 0,
|
|
15594
|
+
collapsedAfter: isLastLine ? collapsedLines : 0,
|
|
15595
|
+
type: "context-expanded",
|
|
15596
|
+
deletionLine: {
|
|
15597
|
+
lineNumber: deletionLineNumber + index,
|
|
15598
|
+
lineIndex: deletionLineIndex + index,
|
|
15599
|
+
noEOFCR: false,
|
|
15600
|
+
unifiedLineIndex: unifiedLineIndex + index,
|
|
15601
|
+
splitLineIndex: splitLineIndex + index
|
|
15602
|
+
},
|
|
15603
|
+
additionLine: {
|
|
15604
|
+
unifiedLineIndex: unifiedLineIndex + index,
|
|
15605
|
+
splitLineIndex: splitLineIndex + index,
|
|
15606
|
+
lineIndex: additionLineIndex + index,
|
|
15607
|
+
lineNumber: additionLineNumber + index,
|
|
15608
|
+
noEOFCR: false
|
|
15616
15609
|
}
|
|
15617
|
-
}
|
|
15618
|
-
|
|
15619
|
-
|
|
15620
|
-
index++;
|
|
15610
|
+
});
|
|
15611
|
+
}, undefined, () => state.shouldBreak())) {
|
|
15612
|
+
break hunkIterator;
|
|
15621
15613
|
}
|
|
15622
15614
|
}
|
|
15623
15615
|
}
|
|
@@ -15696,15 +15688,14 @@ function getHunkPrefixCounts({ diff, expandedHunks, collapsedContextThreshold })
|
|
|
15696
15688
|
const leadingCount = leadingRegion.fromStart + leadingRegion.fromEnd;
|
|
15697
15689
|
splitCount += leadingCount + hunk.splitLineCount;
|
|
15698
15690
|
unifiedCount += leadingCount + hunk.unifiedLineCount;
|
|
15699
|
-
|
|
15700
|
-
|
|
15701
|
-
|
|
15702
|
-
|
|
15703
|
-
|
|
15704
|
-
|
|
15705
|
-
|
|
15706
|
-
|
|
15707
|
-
});
|
|
15691
|
+
const trailingRegion = index === finalHunkIndex ? getTrailingExpandedRegion({
|
|
15692
|
+
fileDiff: diff,
|
|
15693
|
+
hunkIndex: index,
|
|
15694
|
+
expandedHunks,
|
|
15695
|
+
collapsedContextThreshold,
|
|
15696
|
+
errorPrefix: "iterateOverDiff"
|
|
15697
|
+
}) : undefined;
|
|
15698
|
+
if (trailingRegion != null) {
|
|
15708
15699
|
const trailingCount = trailingRegion.fromStart + trailingRegion.fromEnd;
|
|
15709
15700
|
splitCount += trailingCount;
|
|
15710
15701
|
unifiedCount += trailingCount;
|
|
@@ -15716,7 +15707,7 @@ function getHunkPrefixCounts({ diff, expandedHunks, collapsedContextThreshold })
|
|
|
15716
15707
|
}
|
|
15717
15708
|
return prefixCounts;
|
|
15718
15709
|
}
|
|
15719
|
-
function
|
|
15710
|
+
function getContextLineIterationBounds(state, count, diffStyle) {
|
|
15720
15711
|
if (!state.isWindowedHighlight || count <= 0) {
|
|
15721
15712
|
return [0, count];
|
|
15722
15713
|
}
|
|
@@ -15746,20 +15737,31 @@ function getEqualLineIterationRange(state, count, diffStyle) {
|
|
|
15746
15737
|
}
|
|
15747
15738
|
return [start, end];
|
|
15748
15739
|
}
|
|
15749
|
-
function
|
|
15750
|
-
const
|
|
15751
|
-
|
|
15752
|
-
|
|
15753
|
-
|
|
15740
|
+
function walkContextLines(state, count, diffStyle, callback, onSkippedStart, shouldBreak) {
|
|
15741
|
+
const [startIndex, endIndex] = getContextLineIterationBounds(state, count, diffStyle);
|
|
15742
|
+
if (startIndex > 0) {
|
|
15743
|
+
state.incrementCounts(startIndex, startIndex);
|
|
15744
|
+
onSkippedStart?.();
|
|
15754
15745
|
}
|
|
15755
|
-
|
|
15756
|
-
|
|
15757
|
-
|
|
15758
|
-
|
|
15759
|
-
|
|
15760
|
-
|
|
15746
|
+
let index = startIndex;
|
|
15747
|
+
while (index < count) {
|
|
15748
|
+
if (shouldBreak?.() === true) {
|
|
15749
|
+
return true;
|
|
15750
|
+
}
|
|
15751
|
+
if (index >= endIndex) {
|
|
15752
|
+
state.incrementCounts(count - index, count - index);
|
|
15753
|
+
break;
|
|
15754
|
+
}
|
|
15755
|
+
if (state.isInWindow(0, 0)) {
|
|
15756
|
+
if (callback(index) === true) {
|
|
15757
|
+
return true;
|
|
15758
|
+
}
|
|
15759
|
+
} else {
|
|
15760
|
+
state.incrementCounts(1, 1);
|
|
15761
|
+
}
|
|
15762
|
+
index++;
|
|
15761
15763
|
}
|
|
15762
|
-
return
|
|
15764
|
+
return false;
|
|
15763
15765
|
}
|
|
15764
15766
|
function getChangeIterationRanges(state, content, diffStyle) {
|
|
15765
15767
|
if (!state.isWindowedHighlight) {
|