Skip to content

Commit ff95c40

Browse files
update
1 parent 2062d7d commit ff95c40

4 files changed

Lines changed: 25 additions & 6 deletions

File tree

packages/react/src/components/DiffViewWithMultiSelect.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ const InternalDiffViewWithMultiSelect = <T extends unknown>(
307307
}
308308
if (isUnifiedMode && otherMultiResult?.length) {
309309
const max = Math.max(...otherMultiResult);
310-
if (max === lineNum) {
310+
const diffFile = getDiffFile();
311+
const index = diffFile.getUnifiedLineIndexByLineNumber(lineNum, side);
312+
const unifiedItem = diffFile.getUnifiedLine(index);
313+
const otherSideLineNum = side === SplitSide.old ? unifiedItem.newLineNumber : unifiedItem.oldLineNumber;
314+
if (max === otherSideLineNum) {
311315
const finalResult = { [otherSide]: otherMultiResult };
312316
setMultiResult(finalResult as typeof multiResult);
313317
onAddWidgetClick?.({

packages/solid/src/components/DiffViewWithMultiSelect.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,11 @@ const InternalDiffViewWithMultiSelect = <T extends unknown>(props: DiffViewWithM
246246
}
247247
if (isUnifiedMode() && otherSideResult?.length) {
248248
const max = Math.max(...otherSideResult);
249-
if (max === lineNum) {
249+
const diffFile = innerDiffFile();
250+
const index = diffFile?.getUnifiedLineIndexByLineNumber(lineNum, side) ?? -1;
251+
const unifiedItem = diffFile?.getUnifiedLine(index);
252+
const otherSideLineNum = side === SplitSide.old ? unifiedItem?.newLineNumber : unifiedItem?.oldLineNumber;
253+
if (max === otherSideLineNum) {
250254
const finalResult = { [otherSide]: otherSideResult };
251255
setMultiResult(finalResult as ReturnType<typeof extendDataToPreselectedLines>);
252256
props.onAddWidgetClick?.({

packages/svelte/src/lib/components/DiffViewWithMultiSelect.svelte

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@
204204
205205
let isWrapModeInitial = true;
206206
$effect(() => {
207+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
207208
props.diffViewWrap;
209+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
208210
props.diffViewMode;
209211
if (isWrapModeInitial) {
210212
isWrapModeInitial = false;
@@ -230,7 +232,7 @@
230232
if (multiResult) {
231233
const currentSide = SplitSide[side] as unknown as 'new' | 'old';
232234
const currentMultiResult = multiResult[currentSide] as number[];
233-
const otherSide = currentSide === "new" ? "old" : "new";
235+
const otherSide = currentSide === 'new' ? 'old' : 'new';
234236
const otherMultiResult = multiResult[otherSide] as number[];
235237
if (currentMultiResult?.length) {
236238
const max = Math.max(...currentMultiResult);
@@ -247,13 +249,18 @@
247249
}
248250
if (isUnifiedMode && otherMultiResult?.length) {
249251
const max = Math.max(...otherMultiResult);
250-
if (max === lineNum) {
252+
const diffFile = innerDiffFile;
253+
const index = diffFile?.getUnifiedLineIndexByLineNumber(lineNum, side) ?? -1;
254+
const unifiedItem = diffFile?.getUnifiedLine(index);
255+
const otherSideLineNum =
256+
side === SplitSide.old ? unifiedItem?.newLineNumber : unifiedItem?.oldLineNumber;
257+
if (max === otherSideLineNum) {
251258
const finalResult = { [otherSide]: otherMultiResult };
252259
multiResult = finalResult as typeof multiResult;
253260
props.onAddWidgetClick?.({
254261
lineNumber: max,
255262
fromLineNumber: Math.min(...otherMultiResult),
256-
side: otherSide === "old" ? SplitSide.old : SplitSide.new
263+
side: otherSide === 'old' ? SplitSide.old : SplitSide.new
257264
});
258265
return;
259266
}

packages/vue/src/components/DiffViewWithMultiSelect.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,11 @@ export const DiffViewWithMultiSelect = defineComponent<
216216
}
217217
if (isUnifiedMode.value && otherMultiResult?.length) {
218218
const max = Math.max(...otherMultiResult);
219-
if (max === lineNum) {
219+
const diffFile = getDiffFile();
220+
const index = diffFile?.getUnifiedLineIndexByLineNumber(lineNum, side) ?? -1;
221+
const unifiedItem = diffFile?.getUnifiedLine(index);
222+
const otherSideLineNum = side === SplitSide.old ? unifiedItem?.newLineNumber : unifiedItem?.oldLineNumber;
223+
if (max === otherSideLineNum) {
220224
const finalResult = { [otherSide]: otherMultiResult };
221225
multiResult.value = finalResult as typeof multiResult.value;
222226
options.emit("onAddWidgetClick", {

0 commit comments

Comments
 (0)