+ // Row signature; has row changed since last paint?
+ lyx::size_type const row_sig = calculateRowSignature(*rit, par);
+
+ // The following code figures out if the cursor is inside
+ // an inset _on this row_.
+ bool cur_in_inset_in_row = isCursorInInsetInRow(pi, rit, par);
+
+ // If selection is on, the current row signature differs from
+ // from cache, or cursor is inside an inset _on this row_,
+ // then paint the row
+ if (repaintAll || par.rowSignature()[rowno] != row_sig
+ || cur_in_inset_in_row) {
+ // Add to row signature cache
+ par.rowSignature()[rowno] = row_sig;
+
+ bool const inside = (y + rit->descent() >= 0
+ && y - rit->ascent() < ww);
+ RowPainter rp(inside ? pi : nullpi, text, pit, *rit, x, y);
+ // Clear background of this row
+ // (if paragraph background was not cleared)
+ if (!repaintAll) {
+ pi.pain.fillRectangle(x, y - rit->ascent(),
+ pi.base.bv->workWidth(), rit->height(),
+ text.backgroundColor());
+ }
+
+ // Instrumentation for testing row cache (see also
+ // 12 lines lower):
+ //lyxerr << "#";
+ rp.paintAppendix();
+ rp.paintDepthBar();
+ rp.paintChangeBar();
+ if (rit == rb)
+ rp.paintFirst();
+ if (rit + 1 == re)
+ rp.paintLast();
+ rp.paintText();
+ }