void () { myTextAnnotationExtraSize = 0; if (!myEditor.isInDistractionFreeMode() || isMirrored()) return; int marginFromSettings = AdvancedSettings.getInt(DISTRACTION_FREE_MARGIN); if (marginFromSettings != -1) { myTextAnnotationExtraSize = marginFromSettings; return; } Component outerContainer = ComponentUtil.findParentByCondition(myEditor.getComponent(), c -> EditorComposite.isEditorComposite(c)); if (outerContainer == null) return; EditorSettings settings = myEditor.getSettings(); Project project = myEditor.getProject(); if (project != null && project.isDisposed()) return; int rightMargin = settings.getRightMargin(project); if (rightMargin <= 0) return; JComponent editorComponent = myEditor.getComponent(); RelativePoint point = new RelativePoint(editorComponent, new Point(0, 0)); Point editorLocationInWindow = point.getPoint(outerContainer); int editorLocationX = (int)editorLocationInWindow.getX(); int rightMarginX = rightMargin * EditorUtil.getSpaceWidth(Font.PLAIN, myEditor) + editorLocationX; int width = editorLocationX + editorComponent.getWidth(); if (rightMarginX < width && editorLocationX < width - rightMarginX) { int centeredSize = (width - rightMarginX - editorLocationX) / 2 - (getLineMarkerAreaWidth() + getLineNumberAreaWidth() + getFoldingAreaWidth() + 2 * getGapBetweenAreas()); myTextAnnotationExtraSize = Math.max(0, centeredSize - myTextAnnotationGuttersSize); } }