boolean (final SplitHunk splitHunk, final SplitHunk originalHunk) { final int offset = splitHunk.getContextBefore().size(); final List<BeforeAfter<List<String>>> steps = splitHunk.getPatchSteps(); if (splitHunk.isInsertion()) { final boolean emptyFile = myLines.isEmpty() || myLines.size() == 1 && myLines.get(0).trim().isEmpty(); if (emptyFile) { myNotBound.add(splitHunk); processAppliedInfoForUnApplied(splitHunk); } return emptyFile; } int idx = splitHunk.getStartLineBefore() + offset; int cnt = 0; boolean hadAlreadyApplied = false; for (BeforeAfter<List<String>> step : steps) { if (myLines.size() <= idx) return false; if (step.getBefore().isEmpty()) continue; // can occur only in the end final Pair<Integer, Boolean> distance = new FragmentMatcher(idx + cnt, step).find(false); if (distance.getFirst() > 0) { return false; } // fits! int length; if (distance.getSecond()) { length = step.getBefore().size(); } else { length = step.getAfter().size(); hadAlreadyApplied = true; } cnt += length; //idx += length - 1; } putCutIntoTransformations(new TextRange(idx, idx + cnt - 1), originalHunk, new MyAppliedData(splitHunk.getAfterAll(), hadAlreadyApplied, true, true, ChangeType.REPLACE), new IntPair( originalHunk.getContextBefore().size() - splitHunk.getContextBefore().size(), originalHunk.getContextAfter().size() - splitHunk.getContextAfter().size())); return true; }