From 2ad71fb92a5579f7dee48b348c7ae4e5fe406c4b Mon Sep 17 00:00:00 2001 From: Denis Zhdanov Date: Thu, 2 Dec 2010 16:54:06 +0300 Subject: [PATCH] Performing caret row background repainting at soft wrap-introduced virutal space if necessary --- .../openapi/editor/impl/EditorImpl.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 66d2835e67f0..be044f5d7d5c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -1456,7 +1456,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi borderEffect.paintHighlighters(docMarkup.getAllHighlighters()); borderEffect.paintHighlighters(getMarkupModel().getAllHighlighters()); paintCaretCursor(g); - + paintComposedTextDecoration((Graphics2D)g); } @@ -1672,9 +1672,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi return; } + myLastBackgroundPosition = null; + myLastBackgroundColor = null; + boolean locateBeforeSoftWrap = !SoftWrapHelper.isCaretAfterSoftWrap(this); int start = logicalPositionToOffset(logicalPosition); - getSoftWrapModel().registerSoftWrapsIfNecessary(clip, start); + getSoftWrapModel().registerSoftWrapsIfNecessary(); // There is a possible case that we need to draw background from the start of soft wrap-introduced visual line. Given position // has valid 'y' coordinate then at it shouldn't be affected by soft wrap that corresponds to the visual line start offset. @@ -1682,8 +1685,15 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi TIntHashSet softWrapsToSkip = new TIntHashSet(); SoftWrap softWrap = getSoftWrapModel().getSoftWrap(start); if (softWrap != null) { - position.x = softWrap.getIndentInPixels(); softWrapsToSkip.add(softWrap.getStart()); + if (position.y == getCaretModel().getVisualPosition().line * getLineHeight()) { + // There is a possible case that target clip points to soft wrap-introduced visual line and that it's an active + // line (caret cursor is located on it). We want to draw corresponding 'caret line' background for soft wraps-introduced + // virtual space then. + Color caretRowColor = getColorsScheme().getColor(EditorColors.CARET_ROW_COLOR); + drawBackground(g, caretRowColor, softWrap.getIndentInPixels(), position, defaultBackground, clip); + } + position.x = softWrap.getIndentInPixels(); } IterationState iterationState = new IterationState(this, start, paintSelection()); @@ -1694,9 +1704,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi return; } - myLastBackgroundPosition = null; - myLastBackgroundColor = null; - TextAttributes attributes = iterationState.getMergedAttributes(); Color backColor = getBackgroundColor(attributes); int fontType = attributes.getFontType(); @@ -1842,7 +1849,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi } private int drawSoftWrapAwareBackground(Graphics g, Color backColor, CharSequence text, int start, int end, Point position, - int fontType, Color defaultBackground, Rectangle clip, TIntHashSet processSoftWrap, + int fontType, Color defaultBackground, Rectangle clip, TIntHashSet softWrapsToSkip, boolean[] caretRowPainted) { int startToUse = start; @@ -1856,7 +1863,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi List softWraps = getSoftWrapModel().getSoftWrapsForRange(start, softWrapRetrievalEndOffset); for (SoftWrap softWrap : softWraps) { int softWrapStart = softWrap.getStart(); - if (processSoftWrap.contains(softWrapStart)) { + if (softWrapsToSkip.contains(softWrapStart)) { continue; } if (startToUse < softWrapStart) {