Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita34c185

Browse files
committed
1 parentecd834f commita34c185

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

‎src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java‎

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static void write(UnifiedDiff diff, Consumer<String> writer) throws IOExc
8383
// if it isn't, output the current set,
8484
// then create a new set and add the current Delta to
8585
// it.
86-
processDeltas(writer,originalLines,deltas,contextSize);
86+
processDeltas(writer,deltas);
8787
deltas.clear();
8888
deltas.add(nextDelta);
8989
}
@@ -92,7 +92,7 @@ public static void write(UnifiedDiff diff, Consumer<String> writer) throws IOExc
9292

9393
}
9494
// don't forget to process the last set of Deltas
95-
processDeltas(writer,originalLines,deltas,contextSize);
95+
processDeltas(writer,deltas);
9696

9797
}
9898
if (diff.getTail() !=null) {
@@ -102,8 +102,7 @@ public static void write(UnifiedDiff diff, Consumer<String> writer) throws IOExc
102102
}
103103

104104
privatestaticvoidprocessDeltas(Consumer<String>writer,
105-
List<String>origLines,
106-
List<AbstractDelta<String>>deltas,intcontextSize) {
105+
List<AbstractDelta<String>>deltas) {
107106
List<String>buffer =newArrayList<>();
108107
intorigTotal =0;// counter for total lines output from Original
109108
intrevTotal =0;// counter for total lines output from Original
@@ -112,29 +111,28 @@ private static void processDeltas(Consumer<String> writer,
112111
AbstractDelta<String>curDelta =deltas.get(0);
113112

114113
// NOTE: +1 to overcome the 0-offset Position
115-
intorigStart =curDelta.getSource().getPosition() +1 -contextSize;
114+
intorigStart =curDelta.getSource().getPosition() +1;
116115
if (origStart <1) {
117116
origStart =1;
118117
}
119118

120-
intrevStart =curDelta.getTarget().getPosition() +1 -contextSize;
119+
intrevStart =curDelta.getTarget().getPosition() +1;
121120
if (revStart <1) {
122121
revStart =1;
123122
}
124123

125124
// find the start of the wrapper context code
126-
intcontextStart =curDelta.getSource().getPosition() -contextSize;
125+
intcontextStart =curDelta.getSource().getPosition();
127126
if (contextStart <0) {
128127
contextStart =0;// clamp to the start of the file
129128
}
130129

131-
// output the context before the first Delta
132-
for (line =contextStart;line <curDelta.getSource().getPosition();line++) {//
133-
buffer.add(" " +origLines.get(line));
134-
origTotal++;
135-
revTotal++;
136-
}
137-
130+
// // output the context before the first Delta
131+
// for (line = contextStart; line < curDelta.getSource().getPosition(); line++) { //
132+
// buffer.add(" " + curDelta.getSource().getLines().get(line - contextStart));
133+
// origTotal++;
134+
// revTotal++;
135+
// }
138136
// output the first Delta
139137
getDeltaText(txt ->buffer.add(txt),curDelta);
140138
origTotal +=curDelta.getSource().getLines().size();
@@ -145,13 +143,13 @@ private static void processDeltas(Consumer<String> writer,
145143
AbstractDelta<String>nextDelta =deltas.get(deltaIndex);
146144
intintermediateStart =curDelta.getSource().getPosition()
147145
+curDelta.getSource().getLines().size();
148-
for (line =intermediateStart;line <nextDelta.getSource()
149-
.getPosition();line++) {
150-
// output the code between the last Delta and this one
151-
buffer.add(" " +origLines.get(line));
152-
origTotal++;
153-
revTotal++;
154-
}
146+
// for (line = intermediateStart; line < nextDelta.getSource()
147+
// .getPosition(); line++) {
148+
// // output the code between the last Delta and this one
149+
// buffer.add(" " + origLines.get(line));
150+
// origTotal++;
151+
// revTotal++;
152+
// }
155153
getDeltaText(txt ->buffer.add(txt),nextDelta);// output the Delta
156154
origTotal +=nextDelta.getSource().getLines().size();
157155
revTotal +=nextDelta.getTarget().getLines().size();
@@ -162,12 +160,12 @@ private static void processDeltas(Consumer<String> writer,
162160
// Now output the post-Delta context code, clamping the end of the file
163161
contextStart =curDelta.getSource().getPosition()
164162
+curDelta.getSource().getLines().size();
165-
for (line =contextStart; (line < (contextStart +contextSize))
166-
&& (line <origLines.size());line++) {
167-
buffer.add(" " +origLines.get(line));
168-
origTotal++;
169-
revTotal++;
170-
}
163+
// for (line = contextStart; (line < (contextStart + contextSize))
164+
// && (line < origLines.size()); line++) {
165+
// buffer.add(" " + origLines.get(line));
166+
// origTotal++;
167+
// revTotal++;
168+
// }
171169

172170
// Create and insert the block header, conforming to the Unified Diff
173171
// standard

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp