@pierre/diffs 1.2.5 → 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.map +1 -1
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +16 -41
- 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/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 +213 -214
- 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
package/dist/worker/worker.js
CHANGED
|
@@ -741,6 +741,39 @@ function getExpandedRegion({ isPartial, rangeSize, expandedHunks, hunkIndex, col
|
|
|
741
741
|
renderAll
|
|
742
742
|
};
|
|
743
743
|
}
|
|
744
|
+
function getTrailingContextRangeSize({ fileDiff, errorPrefix }) {
|
|
745
|
+
const lastHunk = fileDiff.hunks[fileDiff.hunks.length - 1];
|
|
746
|
+
if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) return 0;
|
|
747
|
+
const additionRemaining = fileDiff.additionLines.length - (lastHunk.additionLineIndex + lastHunk.additionCount);
|
|
748
|
+
const deletionRemaining = fileDiff.deletionLines.length - (lastHunk.deletionLineIndex + lastHunk.deletionCount);
|
|
749
|
+
if (additionRemaining <= 0 && deletionRemaining <= 0) return 0;
|
|
750
|
+
if (additionRemaining !== deletionRemaining) throw new Error(`${errorPrefix}: trailing context mismatch (additions=${additionRemaining}, deletions=${deletionRemaining}) for ${fileDiff.name}`);
|
|
751
|
+
return Math.min(additionRemaining, deletionRemaining);
|
|
752
|
+
}
|
|
753
|
+
function getTrailingExpandedRegion({ fileDiff, hunkIndex, expandedHunks, collapsedContextThreshold, errorPrefix }) {
|
|
754
|
+
if (hunkIndex !== fileDiff.hunks.length - 1) return;
|
|
755
|
+
const trailingRangeSize = getTrailingContextRangeSize({
|
|
756
|
+
fileDiff,
|
|
757
|
+
errorPrefix
|
|
758
|
+
});
|
|
759
|
+
if (trailingRangeSize <= 0) return;
|
|
760
|
+
if (expandedHunks === true || trailingRangeSize <= collapsedContextThreshold) return {
|
|
761
|
+
fromStart: trailingRangeSize,
|
|
762
|
+
fromEnd: 0,
|
|
763
|
+
rangeSize: trailingRangeSize,
|
|
764
|
+
collapsedLines: 0,
|
|
765
|
+
renderAll: true
|
|
766
|
+
};
|
|
767
|
+
const region = expandedHunks?.get(fileDiff.hunks.length);
|
|
768
|
+
const fromStart = Math.min(Math.max(region?.fromStart ?? 0, 0), trailingRangeSize);
|
|
769
|
+
return {
|
|
770
|
+
fromStart,
|
|
771
|
+
fromEnd: 0,
|
|
772
|
+
rangeSize: trailingRangeSize,
|
|
773
|
+
collapsedLines: trailingRangeSize - fromStart,
|
|
774
|
+
renderAll: fromStart >= trailingRangeSize
|
|
775
|
+
};
|
|
776
|
+
}
|
|
744
777
|
|
|
745
778
|
//#endregion
|
|
746
779
|
//#region src/utils/iterateOverDiff.ts
|
|
@@ -753,12 +786,12 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
753
786
|
collapsedContextThreshold
|
|
754
787
|
});
|
|
755
788
|
const state = {
|
|
756
|
-
finalHunk: diff.hunks.at(-1),
|
|
757
789
|
viewportStart: startingLine,
|
|
758
790
|
viewportEnd: startingLine + totalLines,
|
|
759
791
|
isWindowedHighlight: startingLine > 0 || totalLines < Infinity,
|
|
760
792
|
splitCount: iterationStart.splitCount,
|
|
761
793
|
unifiedCount: iterationStart.unifiedCount,
|
|
794
|
+
finalHunkIndex: diff.hunks.length - 1,
|
|
762
795
|
shouldBreak() {
|
|
763
796
|
if (!state.isWindowedHighlight) return false;
|
|
764
797
|
const breakUnified = state.unifiedCount >= startingLine + totalLines;
|
|
@@ -811,31 +844,24 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
811
844
|
hunkIndex,
|
|
812
845
|
collapsedContextThreshold
|
|
813
846
|
});
|
|
814
|
-
const trailingRegion =
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
isPartial: diff.isPartial,
|
|
822
|
-
rangeSize: trailingRangeSize,
|
|
823
|
-
expandedHunks,
|
|
824
|
-
hunkIndex: diff.hunks.length,
|
|
825
|
-
collapsedContextThreshold
|
|
826
|
-
});
|
|
827
|
-
})();
|
|
847
|
+
const trailingRegion = hunkIndex === state.finalHunkIndex ? getTrailingExpandedRegion({
|
|
848
|
+
fileDiff: diff,
|
|
849
|
+
hunkIndex,
|
|
850
|
+
expandedHunks,
|
|
851
|
+
collapsedContextThreshold,
|
|
852
|
+
errorPrefix: "iterateOverDiff"
|
|
853
|
+
}) : void 0;
|
|
828
854
|
const expandedLineCount = leadingRegion.fromStart + leadingRegion.fromEnd;
|
|
829
855
|
function getTrailingCollapsedAfter(unifiedLineIndex$1, splitLineIndex$1) {
|
|
830
856
|
if (trailingRegion == null || trailingRegion.collapsedLines <= 0 || trailingRegion.fromStart + trailingRegion.fromEnd > 0) return 0;
|
|
831
857
|
if (diffStyle === "unified") return unifiedLineIndex$1 === hunk.unifiedLineStart + hunk.unifiedLineCount - 1 ? trailingRegion.collapsedLines : 0;
|
|
832
858
|
return splitLineIndex$1 === hunk.splitLineStart + hunk.splitLineCount - 1 ? trailingRegion.collapsedLines : 0;
|
|
833
859
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
return
|
|
860
|
+
let consumedCollapsed = leadingRegion.collapsedLines === 0;
|
|
861
|
+
function consumePendingCollapsed() {
|
|
862
|
+
if (consumedCollapsed) return 0;
|
|
863
|
+
consumedCollapsed = true;
|
|
864
|
+
return leadingRegion.collapsedLines;
|
|
839
865
|
}
|
|
840
866
|
if (!state.shouldSkip(expandedLineCount, expandedLineCount)) {
|
|
841
867
|
let unifiedLineIndex$1 = hunk.unifiedLineStart - leadingRegion.rangeSize;
|
|
@@ -844,81 +870,63 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
844
870
|
let additionLineIndex$1 = hunk.additionLineIndex - leadingRegion.rangeSize;
|
|
845
871
|
let deletionLineNumber$1 = hunk.deletionStart - leadingRegion.rangeSize;
|
|
846
872
|
let additionLineNumber$1 = hunk.additionStart - leadingRegion.rangeSize;
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
871
|
-
splitLineIndex: splitLineIndex$1 + index,
|
|
872
|
-
lineIndex: additionLineIndex$1 + index,
|
|
873
|
-
lineNumber: additionLineNumber$1 + index,
|
|
874
|
-
noEOFCR: false
|
|
875
|
-
}
|
|
876
|
-
})) break hunkIterator;
|
|
877
|
-
} else state.incrementCounts(1, 1);
|
|
878
|
-
index++;
|
|
879
|
-
}
|
|
873
|
+
if (walkContextLines(state, leadingRegion.fromStart, diffStyle, (index) => {
|
|
874
|
+
return state.emit({
|
|
875
|
+
hunkIndex,
|
|
876
|
+
hunk,
|
|
877
|
+
collapsedBefore: 0,
|
|
878
|
+
collapsedAfter: 0,
|
|
879
|
+
type: "context-expanded",
|
|
880
|
+
deletionLine: {
|
|
881
|
+
lineNumber: deletionLineNumber$1 + index,
|
|
882
|
+
lineIndex: deletionLineIndex$1 + index,
|
|
883
|
+
noEOFCR: false,
|
|
884
|
+
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
885
|
+
splitLineIndex: splitLineIndex$1 + index
|
|
886
|
+
},
|
|
887
|
+
additionLine: {
|
|
888
|
+
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
889
|
+
splitLineIndex: splitLineIndex$1 + index,
|
|
890
|
+
lineIndex: additionLineIndex$1 + index,
|
|
891
|
+
lineNumber: additionLineNumber$1 + index,
|
|
892
|
+
noEOFCR: false
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
})) break hunkIterator;
|
|
880
896
|
unifiedLineIndex$1 = hunk.unifiedLineStart - leadingRegion.fromEnd;
|
|
881
897
|
splitLineIndex$1 = hunk.splitLineStart - leadingRegion.fromEnd;
|
|
882
898
|
deletionLineIndex$1 = hunk.deletionLineIndex - leadingRegion.fromEnd;
|
|
883
899
|
additionLineIndex$1 = hunk.additionLineIndex - leadingRegion.fromEnd;
|
|
884
900
|
deletionLineNumber$1 = hunk.deletionStart - leadingRegion.fromEnd;
|
|
885
901
|
additionLineNumber$1 = hunk.additionStart - leadingRegion.fromEnd;
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
lineIndex: additionLineIndex$1 + index,
|
|
912
|
-
lineNumber: additionLineNumber$1 + index,
|
|
913
|
-
noEOFCR: false
|
|
914
|
-
}
|
|
915
|
-
})) break hunkIterator;
|
|
916
|
-
} else state.incrementCounts(1, 1);
|
|
917
|
-
index++;
|
|
918
|
-
}
|
|
902
|
+
if (walkContextLines(state, leadingRegion.fromEnd, diffStyle, (index) => {
|
|
903
|
+
return state.emit({
|
|
904
|
+
hunkIndex,
|
|
905
|
+
hunk,
|
|
906
|
+
collapsedBefore: consumePendingCollapsed(),
|
|
907
|
+
collapsedAfter: 0,
|
|
908
|
+
type: "context-expanded",
|
|
909
|
+
deletionLine: {
|
|
910
|
+
lineNumber: deletionLineNumber$1 + index,
|
|
911
|
+
lineIndex: deletionLineIndex$1 + index,
|
|
912
|
+
noEOFCR: false,
|
|
913
|
+
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
914
|
+
splitLineIndex: splitLineIndex$1 + index
|
|
915
|
+
},
|
|
916
|
+
additionLine: {
|
|
917
|
+
unifiedLineIndex: unifiedLineIndex$1 + index,
|
|
918
|
+
splitLineIndex: splitLineIndex$1 + index,
|
|
919
|
+
lineIndex: additionLineIndex$1 + index,
|
|
920
|
+
lineNumber: additionLineNumber$1 + index,
|
|
921
|
+
noEOFCR: false
|
|
922
|
+
}
|
|
923
|
+
});
|
|
924
|
+
}, () => {
|
|
925
|
+
consumePendingCollapsed();
|
|
926
|
+
})) break hunkIterator;
|
|
919
927
|
} else {
|
|
920
928
|
state.incrementCounts(expandedLineCount, expandedLineCount);
|
|
921
|
-
|
|
929
|
+
consumePendingCollapsed();
|
|
922
930
|
}
|
|
923
931
|
let unifiedLineIndex = hunk.unifiedLineStart;
|
|
924
932
|
let splitLineIndex = hunk.splitLineStart;
|
|
@@ -932,45 +940,37 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
932
940
|
const isLastContent = content === lastContent;
|
|
933
941
|
if (content.type === "context") {
|
|
934
942
|
if (!state.shouldSkip(content.lines, content.lines)) {
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
lineIndex: additionLineIndex + index,
|
|
964
|
-
lineNumber: additionLineNumber + index,
|
|
965
|
-
noEOFCR: isLastLine && hunk.noEOFCRAdditions
|
|
966
|
-
}
|
|
967
|
-
})) break hunkIterator;
|
|
968
|
-
} else state.incrementCounts(1, 1);
|
|
969
|
-
index++;
|
|
970
|
-
}
|
|
943
|
+
if (walkContextLines(state, content.lines, diffStyle, (index) => {
|
|
944
|
+
const isLastLine = isLastContent && index === content.lines - 1;
|
|
945
|
+
const unifiedRowIndex = unifiedLineIndex + index;
|
|
946
|
+
const splitRowIndex = splitLineIndex + index;
|
|
947
|
+
return state.emit({
|
|
948
|
+
hunkIndex,
|
|
949
|
+
hunk,
|
|
950
|
+
collapsedBefore: consumePendingCollapsed(),
|
|
951
|
+
collapsedAfter: getTrailingCollapsedAfter(unifiedRowIndex, splitRowIndex),
|
|
952
|
+
type: "context",
|
|
953
|
+
deletionLine: {
|
|
954
|
+
lineNumber: deletionLineNumber + index,
|
|
955
|
+
lineIndex: deletionLineIndex + index,
|
|
956
|
+
noEOFCR: isLastLine && hunk.noEOFCRDeletions,
|
|
957
|
+
unifiedLineIndex: unifiedRowIndex,
|
|
958
|
+
splitLineIndex: splitRowIndex
|
|
959
|
+
},
|
|
960
|
+
additionLine: {
|
|
961
|
+
unifiedLineIndex: unifiedRowIndex,
|
|
962
|
+
splitLineIndex: splitRowIndex,
|
|
963
|
+
lineIndex: additionLineIndex + index,
|
|
964
|
+
lineNumber: additionLineNumber + index,
|
|
965
|
+
noEOFCR: isLastLine && hunk.noEOFCRAdditions
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
}, () => {
|
|
969
|
+
consumePendingCollapsed();
|
|
970
|
+
})) break hunkIterator;
|
|
971
971
|
} else {
|
|
972
972
|
state.incrementCounts(content.lines, content.lines);
|
|
973
|
-
|
|
973
|
+
consumePendingCollapsed();
|
|
974
974
|
}
|
|
975
975
|
unifiedLineIndex += content.lines;
|
|
976
976
|
splitLineIndex += content.lines;
|
|
@@ -983,12 +983,13 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
983
983
|
const unifiedCount = content.deletions + content.additions;
|
|
984
984
|
if (!state.shouldSkip(unifiedCount, splitCount)) {
|
|
985
985
|
const iterationRanges = getChangeIterationRanges(state, content, diffStyle);
|
|
986
|
+
if ((iterationRanges[0]?.[0] ?? 0) > 0) consumePendingCollapsed();
|
|
986
987
|
for (const [rangeStart, rangeEnd] of iterationRanges) for (let index = rangeStart; index < rangeEnd; index++) {
|
|
987
988
|
const collapsedAfter = getTrailingCollapsedAfter(unifiedLineIndex + index, diffStyle === "unified" ? splitLineIndex + (index < content.deletions ? index : index - content.deletions) : splitLineIndex + index);
|
|
988
989
|
if (state.emit(getChangeLineData({
|
|
989
990
|
hunkIndex,
|
|
990
991
|
hunk,
|
|
991
|
-
collapsedBefore:
|
|
992
|
+
collapsedBefore: consumePendingCollapsed(),
|
|
992
993
|
collapsedAfter,
|
|
993
994
|
diffStyle,
|
|
994
995
|
index,
|
|
@@ -1005,7 +1006,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
1005
1006
|
}), true)) break hunkIterator;
|
|
1006
1007
|
}
|
|
1007
1008
|
}
|
|
1008
|
-
|
|
1009
|
+
consumePendingCollapsed();
|
|
1009
1010
|
state.incrementCounts(unifiedCount, splitCount);
|
|
1010
1011
|
unifiedLineIndex += unifiedCount;
|
|
1011
1012
|
splitLineIndex += splitCount;
|
|
@@ -1018,41 +1019,30 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
|
|
|
1018
1019
|
if (trailingRegion != null) {
|
|
1019
1020
|
const { collapsedLines, fromStart, fromEnd } = trailingRegion;
|
|
1020
1021
|
const len = fromStart + fromEnd;
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
additionLine: {
|
|
1046
|
-
unifiedLineIndex: unifiedLineIndex + index,
|
|
1047
|
-
splitLineIndex: splitLineIndex + index,
|
|
1048
|
-
lineIndex: additionLineIndex + index,
|
|
1049
|
-
lineNumber: additionLineNumber + index,
|
|
1050
|
-
noEOFCR: false
|
|
1051
|
-
}
|
|
1052
|
-
})) break hunkIterator;
|
|
1053
|
-
} else state.incrementCounts(1, 1);
|
|
1054
|
-
index++;
|
|
1055
|
-
}
|
|
1022
|
+
if (walkContextLines(state, len, diffStyle, (index) => {
|
|
1023
|
+
const isLastLine = index === len - 1;
|
|
1024
|
+
return state.emit({
|
|
1025
|
+
hunkIndex: diff.hunks.length,
|
|
1026
|
+
hunk: void 0,
|
|
1027
|
+
collapsedBefore: 0,
|
|
1028
|
+
collapsedAfter: isLastLine ? collapsedLines : 0,
|
|
1029
|
+
type: "context-expanded",
|
|
1030
|
+
deletionLine: {
|
|
1031
|
+
lineNumber: deletionLineNumber + index,
|
|
1032
|
+
lineIndex: deletionLineIndex + index,
|
|
1033
|
+
noEOFCR: false,
|
|
1034
|
+
unifiedLineIndex: unifiedLineIndex + index,
|
|
1035
|
+
splitLineIndex: splitLineIndex + index
|
|
1036
|
+
},
|
|
1037
|
+
additionLine: {
|
|
1038
|
+
unifiedLineIndex: unifiedLineIndex + index,
|
|
1039
|
+
splitLineIndex: splitLineIndex + index,
|
|
1040
|
+
lineIndex: additionLineIndex + index,
|
|
1041
|
+
lineNumber: additionLineNumber + index,
|
|
1042
|
+
noEOFCR: false
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
1045
|
+
}, void 0, () => state.shouldBreak())) break hunkIterator;
|
|
1056
1046
|
}
|
|
1057
1047
|
}
|
|
1058
1048
|
}
|
|
@@ -1117,15 +1107,14 @@ function getHunkPrefixCounts({ diff, expandedHunks, collapsedContextThreshold })
|
|
|
1117
1107
|
const leadingCount = leadingRegion.fromStart + leadingRegion.fromEnd;
|
|
1118
1108
|
splitCount += leadingCount + hunk.splitLineCount;
|
|
1119
1109
|
unifiedCount += leadingCount + hunk.unifiedLineCount;
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
});
|
|
1110
|
+
const trailingRegion = index === finalHunkIndex ? getTrailingExpandedRegion({
|
|
1111
|
+
fileDiff: diff,
|
|
1112
|
+
hunkIndex: index,
|
|
1113
|
+
expandedHunks,
|
|
1114
|
+
collapsedContextThreshold,
|
|
1115
|
+
errorPrefix: "iterateOverDiff"
|
|
1116
|
+
}) : void 0;
|
|
1117
|
+
if (trailingRegion != null) {
|
|
1129
1118
|
const trailingCount = trailingRegion.fromStart + trailingRegion.fromEnd;
|
|
1130
1119
|
splitCount += trailingCount;
|
|
1131
1120
|
unifiedCount += trailingCount;
|
|
@@ -1137,7 +1126,7 @@ function getHunkPrefixCounts({ diff, expandedHunks, collapsedContextThreshold })
|
|
|
1137
1126
|
}
|
|
1138
1127
|
return prefixCounts;
|
|
1139
1128
|
}
|
|
1140
|
-
function
|
|
1129
|
+
function getContextLineIterationBounds(state, count, diffStyle) {
|
|
1141
1130
|
if (!state.isWindowedHighlight || count <= 0) return [0, count];
|
|
1142
1131
|
const ranges = [];
|
|
1143
1132
|
function pushRange(currentCount) {
|
|
@@ -1157,16 +1146,25 @@ function getEqualLineIterationRange(state, count, diffStyle) {
|
|
|
1157
1146
|
}
|
|
1158
1147
|
return [start, end];
|
|
1159
1148
|
}
|
|
1160
|
-
function
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1149
|
+
function walkContextLines(state, count, diffStyle, callback, onSkippedStart, shouldBreak) {
|
|
1150
|
+
const [startIndex, endIndex] = getContextLineIterationBounds(state, count, diffStyle);
|
|
1151
|
+
if (startIndex > 0) {
|
|
1152
|
+
state.incrementCounts(startIndex, startIndex);
|
|
1153
|
+
onSkippedStart?.();
|
|
1154
|
+
}
|
|
1155
|
+
let index = startIndex;
|
|
1156
|
+
while (index < count) {
|
|
1157
|
+
if (shouldBreak?.() === true) return true;
|
|
1158
|
+
if (index >= endIndex) {
|
|
1159
|
+
state.incrementCounts(count - index, count - index);
|
|
1160
|
+
break;
|
|
1161
|
+
}
|
|
1162
|
+
if (state.isInWindow(0, 0)) {
|
|
1163
|
+
if (callback(index) === true) return true;
|
|
1164
|
+
} else state.incrementCounts(1, 1);
|
|
1165
|
+
index++;
|
|
1166
|
+
}
|
|
1167
|
+
return false;
|
|
1170
1168
|
}
|
|
1171
1169
|
function getChangeIterationRanges(state, content, diffStyle) {
|
|
1172
1170
|
if (!state.isWindowedHighlight) return [[0, diffStyle === "unified" ? content.deletions + content.additions : Math.max(content.deletions, content.additions)]];
|