Commit 3966413
committed
Fix UnifiedDiffReader to use correct DeltaType
finalizeChunk() previously always created ChangeDelta regardless of
whether the hunk contained only insertions, only deletions, or only
context lines. This made it impossible for consumers to determine the
actual type of change from the delta alone.
Now uses InsertDelta when a hunk contains only additions (no context),
DeleteDelta when only deletions (no context), EqualDelta when only
context, and ChangeDelta otherwise. Hunks with context lines still use
ChangeDelta to preserve backward-compatible applyTo behavior.
Fixes #2011 parent b35ebf4 commit 3966413Copy full SHA for 3966413
2 files changed
+40-18Lines changed: 40 additions & 18 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- java-diff-utils/src
- main/java/com/github/difflib/unifieddiff
- test/java/com/github/difflib/unifieddiff
Expand file treeCollapse file tree
Open diff view settings
Collapse file
java-diff-utils/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffReader.java
Copy file name to clipboardExpand all lines: java-diff-utils/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffReader.java+39-17Lines changed: 39 additions & 17 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
15 | 15 | |
16 | 16 | |
17 | 17 | |
| 18 | + |
18 | 19 | |
19 | 20 | |
| 21 | + |
| 22 | + |
| 23 | + |
20 | 24 | |
21 | 25 | |
22 | 26 | |
| ||
298 | 302 | |
299 | 303 | |
300 | 304 | |
301 | | - |
302 | | - |
303 | | - |
304 | | - |
305 | | - |
306 | | - |
307 | | - |
308 | | - |
309 | | - |
310 | | - |
311 | | - |
312 | | - |
313 | | - |
314 | | - |
315 | | - |
316 | | - |
317 | | - |
| 305 | + |
| 306 | + |
| 307 | + |
| 308 | + |
| 309 | + |
| 310 | + |
| 311 | + |
| 312 | + |
| 313 | + |
| 314 | + |
| 315 | + |
| 316 | + |
| 317 | + |
| 318 | + |
| 319 | + |
| 320 | + |
| 321 | + |
| 322 | + |
| 323 | + |
| 324 | + |
| 325 | + |
| 326 | + |
| 327 | + |
| 328 | + |
| 329 | + |
| 330 | + |
| 331 | + |
| 332 | + |
| 333 | + |
| 334 | + |
| 335 | + |
| 336 | + |
| 337 | + |
| 338 | + |
| 339 | + |
318 | 340 | |
319 | 341 | |
320 | 342 | |
|
Collapse file
java-diff-utils/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java
Copy file name to clipboardExpand all lines: java-diff-utils/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
275 | 275 | |
276 | 276 | |
277 | 277 | |
278 | | - |
| 278 | + |
279 | 279 | |
280 | 280 | |
281 | 281 | |
|
0 commit comments