|
204 | 204 |
|
205 | 205 | let isWrapModeInitial = true; |
206 | 206 | $effect(() => { |
| 207 | + // eslint-disable-next-line @typescript-eslint/no-unused-expressions |
207 | 208 | props.diffViewWrap; |
| 209 | + // eslint-disable-next-line @typescript-eslint/no-unused-expressions |
208 | 210 | props.diffViewMode; |
209 | 211 | if (isWrapModeInitial) { |
210 | 212 | isWrapModeInitial = false; |
|
230 | 232 | if (multiResult) { |
231 | 233 | const currentSide = SplitSide[side] as unknown as 'new' | 'old'; |
232 | 234 | const currentMultiResult = multiResult[currentSide] as number[]; |
233 | | - const otherSide = currentSide === "new" ? "old" : "new"; |
| 235 | + const otherSide = currentSide === 'new' ? 'old' : 'new'; |
234 | 236 | const otherMultiResult = multiResult[otherSide] as number[]; |
235 | 237 | if (currentMultiResult?.length) { |
236 | 238 | const max = Math.max(...currentMultiResult); |
|
247 | 249 | } |
248 | 250 | if (isUnifiedMode && otherMultiResult?.length) { |
249 | 251 | 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) { |
251 | 258 | const finalResult = { [otherSide]: otherMultiResult }; |
252 | 259 | multiResult = finalResult as typeof multiResult; |
253 | 260 | props.onAddWidgetClick?.({ |
254 | 261 | lineNumber: max, |
255 | 262 | fromLineNumber: Math.min(...otherMultiResult), |
256 | | - side: otherSide === "old" ? SplitSide.old : SplitSide.new |
| 263 | + side: otherSide === 'old' ? SplitSide.old : SplitSide.new |
257 | 264 | }); |
258 | 265 | return; |
259 | 266 | } |
|
0 commit comments