Runnable (boolean isContentsEqual, CharSequence @NotNull [] texts, @NotNull List<ToggleableLineRange> toggleableLineRanges) { @NotNull List<LineFragment> fragments = new ArrayList<>(); @NotNull List<LineFragmentData> fragmentsData = new ArrayList<>(); for (ToggleableLineRange range : toggleableLineRanges) { List<LineFragment> rangeFragments = range.getFragments(); fragments.addAll(rangeFragments); fragmentsData.addAll(Collections.nCopies(rangeFragments.size(), range.getFragmentData())); } UnifiedFragmentBuilder builder = ReadAction.compute(() -> { myIndicator.checkCanceled(); return new MyUnifiedFragmentBuilder(fragments, fragmentsData, myDocument1, myDocument2).exec(); }); Runnable applyChanges = apply(builder, texts, myIndicator); Runnable applyGutterExcludeOperations = applyGutterOperations(builder, toggleableLineRanges); return () -> { applyChanges.run(); applyGutterExcludeOperations.run(); }; }