int (@NotNull Graphics g, @Nullable Color backColor, @Nullable Color prevBackColor, @NotNull CharSequence text, int start, int end, @NotNull Point position, @JdkConstants.FontStyle int fontType, @NotNull Color defaultBackground, @NotNull Rectangle clip, @NotNull TIntHashSet softWrapsToSkip, @NotNull boolean[] caretRowPainted) { int startToUse = start; // Given 'end' offset is exclusive though SoftWrapModel.getSoftWrapsForRange() uses inclusive end offset. // Hence, we decrement it if necessary. Please note that we don't do that if start is equal to end. That is the case, // for example, for soft-wrapped collapsed fold region - we need to draw soft wrap before it. int softWrapRetrievalEndOffset = end; if (end > start) { softWrapRetrievalEndOffset--; } List<? extends SoftWrap> softWraps = getSoftWrapModel().getSoftWrapsForRange(start, softWrapRetrievalEndOffset); for (SoftWrap softWrap : softWraps) { int softWrapStart = softWrap.getStart(); if (softWrapsToSkip.contains(softWrapStart)) { continue; } if (startToUse < softWrapStart) { position.x = drawBackground(g, backColor, text, startToUse, softWrapStart, position, fontType, defaultBackground, clip); } boolean drawCustomBackgroundAtSoftWrapVirtualSpace = !Comparing.equal(backColor, defaultBackground) && (softWrapStart > start || Comparing.equal(prevBackColor, backColor)); drawSoftWrap( g, softWrap, position, fontType, backColor, drawCustomBackgroundAtSoftWrapVirtualSpace, defaultBackground, clip, caretRowPainted ); startToUse = softWrapStart; } if (startToUse < end) { position.x = drawBackground(g, backColor, text, startToUse, end, position, fontType, defaultBackground, clip); } return position.x; }