IDEA-84772 Scrollbars are blinking in commit dialog when message has the same amount of lines visible in message field

This commit is contained in:
Denis.Zhdanov
2012-05-11 09:43:30 +04:00
parent 9cc33837ea
commit 983bbb5b76
2 changed files with 32 additions and 1 deletions
@@ -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);
@@ -92,6 +92,7 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
* during viewport's <code>'y'</code> 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.