diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/apply/GenericPatchApplier.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/apply/GenericPatchApplier.java index b8b4ee3ead59..ad2d9e7e60a3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/apply/GenericPatchApplier.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/apply/GenericPatchApplier.java @@ -180,7 +180,8 @@ public class GenericPatchApplier { final List>> steps = copy.getPatchSteps(); final BeforeAfter> first = steps.get(0); - final BeforeAfter> last = steps.get(steps.size() - 1); + final int lastStepIndex = steps.size() - 1; + final BeforeAfter> last = steps.get(lastStepIndex); final BeforeAfter> firstCopy = copyBeforeAfter(first); steps.set(0, firstCopy); @@ -194,6 +195,7 @@ public class GenericPatchApplier { final BeforeAfter> lastCopy = copyBeforeAfter(last); lastCopy.getBefore().addAll(hunk.getContextAfter()); lastCopy.getAfter().addAll(hunk.getContextAfter()); + steps.set(lastStepIndex, lastCopy); } return copy; }