diff --git a/platform/util/src/com/intellij/util/diff/PatienceIntLCS.java b/platform/util/src/com/intellij/util/diff/PatienceIntLCS.java index 8f04dfa10257..5acb8272c8fb 100644 --- a/platform/util/src/com/intellij/util/diff/PatienceIntLCS.java +++ b/platform/util/src/com/intellij/util/diff/PatienceIntLCS.java @@ -55,7 +55,7 @@ public class PatienceIntLCS { return; } - int startOffset = matchForward(0, 0); + int startOffset = matchForward(myStart1, myStart2); int start1 = myStart1 + startOffset; int start2 = myStart2 + startOffset; diff --git a/platform/util/testSrc/com/intellij/util/diff/PatienceIntLCSTest.java b/platform/util/testSrc/com/intellij/util/diff/PatienceIntLCSTest.java index eb9c1dc2905e..e82a990e45d3 100644 --- a/platform/util/testSrc/com/intellij/util/diff/PatienceIntLCSTest.java +++ b/platform/util/testSrc/com/intellij/util/diff/PatienceIntLCSTest.java @@ -70,6 +70,13 @@ public class PatienceIntLCSTest extends TestCase { new int[]{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}); } + public void testBug1() throws FilesTooBigForDiffException { + BitSet[] change = buildChange(new int[]{2, 3, 4, 6, 7, 8, 9, 11, 12, 4, 6, 11, 15}, + new int[]{2, 3, 6, 7, 8, 9, 6, 11, 12, 4, 11, 15, 6}); + checkChange(change, new int[]{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, + new int[]{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0}); + } + public void testInnerChunks1() throws FilesTooBigForDiffException { BitSet[] change = buildChange(new int[]{0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0}, new int[]{1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1}); checkChange(change, new int[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}, new int[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1});