@NotNull
  Dimension getPreferredSize() {
    Insets insets = myView.getInsets();
    int widthWithoutCaret = getTextPreferredWidth() + insets.left;
    int width = widthWithoutCaret;
    if (!myDocument.isInBulkUpdate() &&
        !myEditor.getInlayModel().isInBatchMode() &&
        !myEditor.isRightAligned() &&
        myEditor.getSettings().isVirtualSpace()) {
      CaretModelImpl caretModel = myEditor.getCaretModel();
      int caretMaxX = (caretModel.isIteratingOverCarets() ? Stream.of(caretModel.getCurrentCaret()) : caretModel.getAllCarets().stream())
        .filter(caret -> caret.isUpToDate() && ((CaretImpl)caret).isInVirtualSpace())
        .mapToInt(c -> (int)myView.visualPositionToXY(c.getVisualPosition()).getX())
        .max().orElse(0);
      width = Math.max(width, caretMaxX);
    }
    width = Math.max(width, insets.left + getMaximumVisibleBlockInlayWidth());
    if (shouldRespectAdditionalColumns(widthWithoutCaret)) {
      width += myEditor.getSettings().getAdditionalColumnsCount() * myView.getPlainSpaceWidth();
    }
    return new Dimension(width + insets.right, getPreferredHeight());
  }
@NotNull
  Dimension getPreferredSize()