List<Range> (@NotNull List<Range> fragments, int hunkStart, int contextLineCount) { int hunkEnd = hunkStart + 1; while (hunkEnd < fragments.size()) { Range lastFragment = fragments.get(hunkEnd - 1); Range nextFragment = fragments.get(hunkEnd); if (lastFragment.end1 + contextLineCount < nextFragment.start1 - contextLineCount && lastFragment.end2 + contextLineCount < nextFragment.start2 - contextLineCount) { break; } hunkEnd++; } return fragments.subList(hunkStart, hunkEnd); }