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 35762cecc63b..533d365499d8 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 @@ -2577,6 +2577,11 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi BorderEffect.paintFoldedEffect(g, foldingXStart, position.y, foldingXEnd, getLineHeight(), effectColor, effectType); // myBorderEffect.collapsedFolderReached(g, this); } + + final SoftWrap softWrap = mySoftWrapModel.getSoftWrap(clipEndOffset); + if (softWrap != null) { + mySoftWrapModel.paint(g, SoftWrapDrawingType.BEFORE_SOFT_WRAP_LINE_FEED, position.x, position.y, getLineHeight()); + } } finally { iterationState.dispose(); @@ -2592,7 +2597,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi } if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == myEditorComponent) { - // There is a possible case that placeholder text was painted and the editor gets focus now. We want to over-paint previuosly + // There is a possible case that placeholder text was painted and the editor gets focus now. We want to over-paint previously // used placeholder text then. myLastBackgroundColor = getBackgroundColor(); myLastBackgroundPosition = new Point(0, 0); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java index 11c045d12567..10693301cebc 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java @@ -92,6 +92,7 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume * during viewport's 'y' coordinate adjustment on visual area width change. */ private int myLastTopLeftCornerOffset = -1; + private int myVerticalScrollBarWidth = -1; private VisibleAreaWidthProvider myWidthProvider; private EditorTextRepresentationHelper myRepresentationHelper; @@ -810,6 +811,31 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume return recalculateSoftWraps(); // Recalculate existing dirty regions if any. } + final JScrollBar scrollBar = myEditor.getScrollPane().getVerticalScrollBar(); + if (myVerticalScrollBarWidth < 0) { + myVerticalScrollBarWidth = scrollBar.getWidth(); + if (myVerticalScrollBarWidth <= 0) { + myVerticalScrollBarWidth = scrollBar.getPreferredSize().width; + } + } + + // We experienced the following situation: + // 1. Editor is configured to show scroll bars only when necessary; + // 2. Editor with active soft wraps is changed in order for the vertical scroll bar to appear; + // 3. Vertical scrollbar consumes vertical space, hence, soft wraps are recalculated because of the visual area width change; + // 4. Newly recalculated soft wraps trigger editor size update; + // 5. Editor size update starts scroll pane update which, in turn, disables vertical scroll bar at first (the reason for that + // lays somewhere at the swing depth); + // 6. Soft wraps are recalculated because of visible area width change caused by the disabled vertical scroll bar; + // 7. Go to the step 4; + // I.e. we have an endless EDT activity that stops only when editor is re-sized in a way to avoid vertical scroll bar. + // That's why we don't recalculate soft wraps when visual area width is changed to the vertical scroll bar width value assuming + // that such a situation is triggered by the scroll bar (dis)appearance. + if (Math.abs(currentVisibleAreaWidth - myVisibleAreaWidth) == myVerticalScrollBarWidth) { + myVisibleAreaWidth = currentVisibleAreaWidth; + return recalculateSoftWraps(); + } + // We want to adjust viewport's 'y' coordinate on complete recalculation, so, we remember number of soft-wrapped lines // before the target offset on recalculation start and compare it with the number of soft-wrapped lines before the same offset // after the recalculation.