Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork209
Description
Describe the bug
A clear and concise description of what the bug is.
This is not bug, but a improvement issue. we need to get exact changed lines when using UnifiedDiffUtils.parseUnifiedDiff in current version we will get aPatch<String>
java-diff-utils/java-diff-utils/src/main/java/com/github/difflib/UnifiedDiffUtils.java
Line 43 in73c4c30
| publicstaticPatch<String>parseUnifiedDiff(List<String>diff) { |
InPatch<String>, the core is the structureChunk<T>
java-diff-utils/java-diff-utils/src/main/java/com/github/difflib/UnifiedDiffUtils.java
Lines 110 to 112 in73c4c30
| patch.addDelta(newChangeDelta<>(newChunk<>( | |
| old_ln -1,oldChunkLines),newChunk<>( | |
| new_ln -1,newChunkLines))); |
but now the information that we can use only theposition andlines
java-diff-utils/java-diff-utils/src/main/java/com/github/difflib/patch/Chunk.java
Lines 38 to 39 ine11c159
| privatefinalintposition; | |
| privateList<T>lines; |
and in thelines, we can't tell the difference between no changed lines and changed lines, because we do not do this work when we get thelines:
java-diff-utils/java-diff-utils/src/main/java/com/github/difflib/UnifiedDiffUtils.java
Lines 93 to 115 ine11c159
| privatestaticvoidprocessLinesInPrevChunk(List<String[]>rawChunk,Patch<String>patch,intold_ln,intnew_ln) { | |
| Stringtag; | |
| Stringrest; | |
| if (!rawChunk.isEmpty()) { | |
| List<String>oldChunkLines =newArrayList<>(); | |
| List<String>newChunkLines =newArrayList<>(); | |
| for (String[]raw_line :rawChunk) { | |
| tag =raw_line[0]; | |
| rest =raw_line[1]; | |
| if (" ".equals(tag) ||"-".equals(tag)) { | |
| oldChunkLines.add(rest); | |
| } | |
| if (" ".equals(tag) ||"+".equals(tag)) { | |
| newChunkLines.add(rest); | |
| } | |
| } | |
| patch.addDelta(newChangeDelta<>(newChunk<>( | |
| old_ln -1,oldChunkLines),newChunk<>( | |
| new_ln -1,newChunkLines))); | |
| rawChunk.clear(); | |
| } | |
| } |
we do not make full use oftag, actually we can:
java-diff-utils/java-diff-utils/src/main/java/com/github/difflib/UnifiedDiffUtils.java
Line 103 ine11c159
| if (" ".equals(tag) ||"-".equals(tag)) { |
java-diff-utils/java-diff-utils/src/main/java/com/github/difflib/UnifiedDiffUtils.java
Line 106 ine11c159
| if (" ".equals(tag) ||"+".equals(tag)) { |
To Reproduce
Steps to reproduce the behavior:
- Example data
- simple programm snippet
- See error
no reproduce, this is improvement issue.
Expected behavior
A clear and concise description of what you expected to happen.
System
- Java version
- Version [e.g. 22]
latest master branch in Github.